R version 3.2.2 (2015-08-14) -- "Fire Safety" Copyright (C) 2015 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > x <- c(98.91,98.15,98.59,98.6,98.7,98.33,98.33,98.6,98.52,99.17,99.49,98.83,98.83,97.39,99.28,98.78,98.75,98.47,98.47,97.82,97.79,97.96,98.21,98.34,98.34,98.49,98.14,98.05,97.77,97.59,97.59,97.67,97.67,97.36,97.31,97.24,97.24,96.89,96.48,96.47,97.13,97.21,97.43,97.98,97.97,98.2,98.67,98.75,98.77,98.72,99.23,99.67,99.76,99.57,99.57,100.21,100.62,101.05,101.42,101.42,101.52,101.87,101.53,101.77,101.76,102.04,102.05,101.9,102.17,102.14,102.09,102.27) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '48' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P., (2012), (Partial) Autocorrelation Function (v1.0.11) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_autocorrelation.wasp/ > #Source of accompanying publication: > # > if (par1 == 'Default') { + par1 = 10*log10(length(x)) + } else { + par1 <- as.numeric(par1) + } > par2 <- as.numeric(par2) > par3 <- as.numeric(par3) > par4 <- as.numeric(par4) > par5 <- as.numeric(par5) > if (par6 == 'White Noise') par6 <- 'white' else par6 <- 'ma' > par7 <- as.numeric(par7) > if (par8 != '') par8 <- as.numeric(par8) > ox <- x > if (par8 == '') { + if (par2 == 0) { + x <- log(x) + } else { + x <- (x ^ par2 - 1) / par2 + } + } else { + x <- log(x,base=par8) + } > if (par3 > 0) x <- diff(x,lag=1,difference=par3) > if (par4 > 0) x <- diff(x,lag=par5,difference=par4) > postscript(file="/var/wessaorg/rcomp/tmp/1b9qr1445605220.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op <- par(mfrow=c(2,1)) > plot(ox,type='l',main='Original Time Series',xlab='time',ylab='value') > if (par8=='') { + mytitle <- paste('Working Time Series (lambda=',par2,', d=',par3,', D=',par4,')',sep='') + mysub <- paste('(lambda=',par2,', d=',par3,', D=',par4,', CI=', par7, ', CI type=',par6,')',sep='') + } else { + mytitle <- paste('Working Time Series (base=',par8,', d=',par3,', D=',par4,')',sep='') + mysub <- paste('(base=',par8,', d=',par3,', D=',par4,', CI=', par7, ', CI type=',par6,')',sep='') + } > plot(x,type='l', main=mytitle,xlab='time',ylab='value') > par(op) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/2trpp1445605220.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > racf <- acf(x, par1, main='Autocorrelation', xlab='time lag', ylab='ACF', ci.type=par6, ci=par7, sub=mysub) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/342pg1445605220.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > rpacf <- pacf(x,par1,main='Partial Autocorrelation',xlab='lags',ylab='PACF',sub=mysub) > dev.off() null device 1 > (myacf <- c(racf$acf)) [1] 1.00000000 0.94021554 0.89813246 0.84466063 0.79895097 0.75179996 [7] 0.69646648 0.63801528 0.57637478 0.50928868 0.45111303 0.38150384 [13] 0.31508504 0.24399218 0.17734877 0.11596978 0.05564347 -0.00127556 [19] -0.04450974 -0.09300775 -0.14092845 -0.18864988 -0.22796770 -0.25821054 [25] -0.28476544 -0.30427532 -0.32617595 -0.34487876 -0.35295393 -0.36003452 [31] -0.35707114 -0.34420775 -0.32855551 -0.30242939 -0.27692038 -0.26057614 [37] -0.24464048 -0.23512819 -0.22814888 -0.21937457 -0.20775473 -0.19373816 [43] -0.18469433 -0.17197049 -0.16465509 -0.15932680 -0.14947567 -0.14468709 [49] -0.14151872 > (mypacf <- c(rpacf$acf)) [1] 0.940215545 0.121791622 -0.100130744 0.015140865 -0.016411937 [6] -0.108270815 -0.078004597 -0.062343892 -0.099425375 0.020299415 [11] -0.114308570 -0.058407981 -0.065834580 -0.028355086 -0.001330541 [16] -0.028498801 -0.021801007 0.086760253 -0.052146455 -0.087269291 [21] -0.035163182 0.005947969 0.029298557 -0.004989484 0.012656165 [26] -0.050843485 -0.023093436 0.034692117 -0.021527436 0.029462259 [31] 0.104031351 0.028959463 0.058181146 0.013215241 -0.123403693 [36] -0.066418016 -0.088710284 -0.111120256 -0.015566202 0.015017844 [41] -0.004406016 -0.035951318 0.001800401 -0.037758289 -0.010442512 [46] 0.046197156 -0.008448951 -0.022434184 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Autocorrelation Function',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Time lag k',header=TRUE) > a<-table.element(a,hyperlink('http://www.xycoon.com/basics.htm','ACF(k)','click here for more information about the Autocorrelation Function'),header=TRUE) > a<-table.element(a,'T-STAT',header=TRUE) > a<-table.element(a,'P-value',header=TRUE) > a<-table.row.end(a) > for (i in 2:(par1+1)) { + a<-table.row.start(a) + a<-table.element(a,i-1,header=TRUE) + a<-table.element(a,round(myacf[i],6)) + mytstat <- myacf[i]*sqrtn + a<-table.element(a,round(mytstat,4)) + a<-table.element(a,round(1-pt(abs(mytstat),lengthx),6)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/4ibzz1445605220.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Partial Autocorrelation Function',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Time lag k',header=TRUE) > a<-table.element(a,hyperlink('http://www.xycoon.com/basics.htm','PACF(k)','click here for more information about the Partial Autocorrelation Function'),header=TRUE) > a<-table.element(a,'T-STAT',header=TRUE) > a<-table.element(a,'P-value',header=TRUE) > a<-table.row.end(a) > for (i in 1:par1) { + a<-table.row.start(a) + a<-table.element(a,i,header=TRUE) + a<-table.element(a,round(mypacf[i],6)) + mytstat <- mypacf[i]*sqrtn + a<-table.element(a,round(mytstat,4)) + a<-table.element(a,round(1-pt(abs(mytstat),lengthx),6)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/5beos1445605220.tab") > > try(system("convert tmp/1b9qr1445605220.ps tmp/1b9qr1445605220.png",intern=TRUE)) character(0) > try(system("convert tmp/2trpp1445605220.ps tmp/2trpp1445605220.png",intern=TRUE)) character(0) > try(system("convert tmp/342pg1445605220.ps tmp/342pg1445605220.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.225 0.242 1.472