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(1.38,1.96,1.36,1.24,1.35,1.23,1.09,1.08,1.33,1.35,1.38,1.5,1.47,2.09,1.52,1.29,1.52,1.27,1.35,1.29,1.41,1.39,1.45,1.53,1.45,2.11,1.53,1.38,1.54,1.35,1.29,1.33,1.47,1.47,1.54,1.59,1.5,2,1.51,1.4,1.62,1.44,1.29,1.28,1.4,1.39,1.46,1.49,1.45,2.05,1.59,1.42,1.73,1.39,1.23,1.37,1.51,1.47,1.5,1.54,1.54,2.15,1.62,1.4,1.65,1.49,1.45,1.45,1.51,1.48,1.56,1.57,1.57,2.28,1.7,1.56,1.8,1.56,1.51,1.46,1.51,1.55,1.57,1.64) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/18zda1384775046.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/2w6ao1384775046.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/36ush1384775046.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.000000000 -0.398184151 -0.190290297 0.296543281 -0.145586613 [6] 0.009086533 -0.132789966 0.002113245 -0.120769741 0.248633657 [11] -0.148129650 -0.333495554 0.811003314 -0.328931622 -0.157858236 [16] 0.268638470 -0.133799305 0.023923655 -0.099112186 -0.024973032 [21] -0.100632899 0.215539668 -0.126484705 -0.282030095 0.669062719 [26] -0.269608196 -0.124057969 0.229714527 -0.101855772 -0.008537857 [31] -0.085953433 0.001553153 -0.066233967 0.137657917 -0.088763654 [36] -0.228181514 0.525875596 -0.207103764 -0.104099897 0.195264683 [41] -0.079235187 0.001523707 -0.070775170 0.006354072 -0.056836260 [46] 0.093023671 -0.077775849 -0.173549829 0.426952883 > (mypacf <- c(rpacf$acf)) [1] -0.398184151 -0.414571479 0.034850093 -0.063387871 0.041578065 [6] -0.267878315 -0.221930331 -0.497602901 0.016309617 -0.226831022 [11] -0.709802458 0.191973108 -0.043835233 0.047290094 -0.144877494 [16] -0.098270213 -0.116013409 0.031544360 -0.054040410 -0.052607733 [21] -0.079209871 -0.074432686 -0.088302746 -0.041212194 -0.037412112 [26] 0.016407079 -0.029391107 0.087176981 -0.089724235 -0.144028913 [31] -0.073041073 0.135896539 -0.018002440 0.021451669 -0.080100488 [36] -0.096307094 -0.066523909 -0.048559168 -0.087195846 -0.132861900 [41] -0.050755643 -0.013609864 -0.006743256 -0.101204707 -0.069858117 [46] -0.135434087 -0.025157894 0.009705966 > 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/4p96t1384775046.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/5vz9c1384775046.tab") > > try(system("convert tmp/18zda1384775046.ps tmp/18zda1384775046.png",intern=TRUE)) character(0) > try(system("convert tmp/2w6ao1384775046.ps tmp/2w6ao1384775046.png",intern=TRUE)) character(0) > try(system("convert tmp/36ush1384775046.ps tmp/36ush1384775046.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.664 0.522 3.155