R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: i686-pc-linux-gnu (32-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(2.7,3,-0.3,1.1,1.7,1.6,3,3.3,6.7,5.6,6,4.8,5.9,4.3,3.7,5.6,1.7,3.2,3.6,1.7,0.5,2.1,1.5,2.7,1.4,1.2,2.3,1.6,4.7,3.5,4.4,3.9,3.5,3,1.6,2.2,4.1,4.3,3.5,1.8,0.6,-0.4,-2.5,-1.6,-1.9,-1.6,-0.7,-1.1,0.3,1.3,3.3,2.4,2,3.9,4.2,4.9,5.8,4.8,4.4,5.3,2.1,2,-0.9,0.1,-0.5,-0.1,0.7,-0.4,-1.5,-0.3,1,0.4,0.3,1.8,3,2.2,3.4,3.4,3.1,4.5,4.6,5.7,4.3,4.5) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '60' > #'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/1rglg1384333572.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/2w1nw1384333572.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/3wj1m1384333572.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.79591166 0.68900840 0.52602249 0.34337464 0.18619512 [7] 0.01313303 -0.09849773 -0.24475104 -0.33677216 -0.42913983 -0.48350443 [13] -0.53813712 -0.46293687 -0.40182104 -0.29117436 -0.19244777 -0.05195181 [19] 0.10485173 0.18245823 0.34349233 0.37530814 0.43765979 0.41710694 [25] 0.36526629 0.31468761 0.24139994 0.17931311 0.09591657 -0.02494687 [31] -0.14824926 -0.25100696 -0.35766175 -0.39926930 -0.47532285 -0.42307353 [37] -0.37733678 -0.30500703 -0.20478308 -0.16065485 -0.04690228 0.04028345 [43] 0.12403636 0.16416288 0.20052964 0.19540818 0.18602347 0.14223853 [49] 0.11619969 0.07630529 0.01480694 -0.02154347 -0.09859090 -0.14420015 [55] -0.21130873 -0.18858829 -0.20561677 -0.18983392 -0.14013470 -0.12509726 [61] -0.09993134 > (mypacf <- c(rpacf$acf)) [1] 0.795911662 0.151512408 -0.167182835 -0.213457419 -0.086919874 [6] -0.139029678 0.002718736 -0.174638685 -0.077328597 -0.128683398 [11] -0.062879246 -0.164708882 0.229201719 0.013714947 0.074564224 [16] -0.095255318 0.152029884 0.119510958 -0.034677163 0.162532436 [21] -0.097394932 0.023694139 -0.115723837 -0.092493321 0.061064595 [26] 0.105372664 0.012604104 -0.006561409 -0.161522558 -0.046917886 [31] -0.072229366 0.049367102 -0.007607567 -0.136057142 0.062704824 [36] 0.021078832 0.031427427 0.011264453 -0.097193593 -0.021438541 [41] 0.068627642 -0.091848914 -0.122228748 -0.020305390 -0.122526010 [46] -0.073581688 -0.034458707 0.045090966 0.069909613 -0.068852980 [51] 0.024214331 0.031527485 -0.040317006 -0.008776777 0.069249159 [56] -0.040768580 -0.019729561 -0.074573184 -0.049354296 -0.058668707 > 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/42ex31384333572.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/55zon1384333572.tab") > > try(system("convert tmp/1rglg1384333572.ps tmp/1rglg1384333572.png",intern=TRUE)) character(0) > try(system("convert tmp/2w1nw1384333572.ps tmp/2w1nw1384333572.png",intern=TRUE)) character(0) > try(system("convert tmp/3wj1m1384333572.ps tmp/3wj1m1384333572.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.247 0.450 2.674