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.19,2.2,2.2,2.22,2.21,2.21,2.21,2.2,2.21,2.2,2.23,2.27,2.3,2.33,2.3,2.32,2.29,2.25,2.24,2.22,2.28,2.38,2.4,2.44,2.44,2.48,2.54,2.58,2.58,2.57,2.58,2.59,2.58,2.59,2.59,2.58,2.58,2.57,2.57,2.56,2.56,2.52,2.51,2.52,2.52,2.48,2.5,2.5,2.5,2.52,2.5,2.49,2.5,2.46,2.49,2.49,2.5,2.51,2.55,2.62,2.65,2.65,2.65,2.65,2.66,2.66,2.66,2.67,2.66,2.67,2.68,2.67) > 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/1acy01384773915.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/2s4a81384773915.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/3abrm1384773915.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.953930987 0.898631980 0.838361375 0.779116582 [6] 0.718426853 0.654599482 0.590827685 0.527864034 0.466623191 [11] 0.404245388 0.340888084 0.282412071 0.229771377 0.188532711 [16] 0.150061190 0.115338630 0.077957758 0.036695936 -0.001222156 [21] -0.043646411 -0.073939222 -0.089502485 -0.103685648 -0.110871060 [26] -0.116389238 -0.115581189 -0.103667510 -0.089771674 -0.077042902 [31] -0.064309499 -0.048023961 -0.036779491 -0.027561172 -0.022237698 [36] -0.021471330 -0.024595175 -0.032276126 -0.046903885 -0.065810878 [41] -0.089437069 -0.112204172 -0.138766548 -0.162656718 -0.185884626 [46] -0.210557470 -0.236212129 -0.254799569 -0.271043619 -0.289788520 [51] -0.303693811 -0.317311967 -0.321151333 -0.316392866 -0.319688065 [56] -0.320102655 -0.325250336 -0.332963705 -0.337812674 -0.340371511 [61] -0.329323867 > (mypacf <- c(rpacf$acf)) [1] 0.9539309865 -0.1261152225 -0.0753682039 -0.0118277969 -0.0503309468 [6] -0.0697486040 -0.0300901919 -0.0290694783 -0.0249315354 -0.0578881489 [11] -0.0535388815 0.0122256611 0.0109931689 0.0710142140 -0.0277470764 [16] -0.0057366423 -0.0745374594 -0.0879816695 0.0002016525 -0.0981381118 [21] 0.1000826781 0.1216934491 -0.0567227472 0.0457800294 -0.0060907203 [26] 0.0349385599 0.1149777676 -0.0169456869 -0.0328348644 -0.0156275138 [31] -0.0032303173 -0.0775608515 -0.0193664035 0.0028915453 -0.0263609162 [36] -0.0395834207 -0.0365921388 -0.1097301233 -0.0265980079 -0.0565478519 [41] -0.0209570104 -0.0212464034 -0.0068528496 -0.0259764945 -0.0465102603 [46] -0.0537595767 0.0970366210 0.0198933697 -0.0766934611 0.0282172377 [51] -0.0346883435 0.0810229702 0.0603745111 -0.1333341649 0.0254365895 [56] -0.0852141542 -0.0874268191 -0.0156517151 -0.0368769751 0.1469775178 > 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/43rcj1384773915.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/562uw1384773915.tab") > > try(system("convert tmp/1acy01384773915.ps tmp/1acy01384773915.png",intern=TRUE)) character(0) > try(system("convert tmp/2s4a81384773915.ps tmp/2s4a81384773915.png",intern=TRUE)) character(0) > try(system("convert tmp/3abrm1384773915.ps tmp/3abrm1384773915.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.982 0.770 4.718