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(71.4,75.8,79.2,84.4,84.4,87.2,92.4,88.5,94.8,100.9,110,107.9,111.2,116.7,125.8,131.5,146.2,155.4,157.5,137.2,121.3,89.1,69.6,56.7,58.5,56.4,60.5,64.6,73.2,84.6,80.4,88.4,84.6,90.8,94.9,93.1,96.6,93.1,98.3,105,95.6,94.3,95.3,97.1,98.1,104.4,107.8,114.3,118.7,124.1,134.2,142.4,133.8,131,133.2,125.9,126.2,122.7,126.6,124.8,128,134.1,138.8,134,124,110.4,116.7,124.7,126,122.8,120.2,121.2) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/fisher/rcomp/tmp/1det01384527371.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/fisher/rcomp/tmp/207sa1384527371.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/fisher/rcomp/tmp/31h4j1384527371.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.000000e+00 5.181463e-01 3.422796e-01 4.362285e-02 -6.183078e-02 [6] -1.836982e-01 -2.490700e-01 -2.398712e-01 -1.732881e-01 -1.685442e-01 [11] -9.241480e-02 -3.796436e-02 -8.061916e-03 -4.942479e-02 -6.422121e-02 [16] -3.640770e-03 -5.565051e-03 8.340559e-06 -2.232351e-02 1.959640e-02 [21] -5.146219e-03 4.356745e-02 1.801124e-02 1.881571e-02 -1.059282e-01 [26] -4.639536e-02 -1.769797e-01 -1.281823e-01 -9.861066e-02 -6.942932e-02 [31] -2.491121e-02 9.038522e-03 6.939301e-02 1.921007e-01 1.261178e-01 [36] 5.935629e-02 1.522110e-02 -1.135338e-02 -4.229565e-03 -7.758260e-02 [41] -2.762707e-02 -2.890862e-03 8.665546e-02 1.053339e-01 1.471800e-01 [46] 6.275929e-02 1.147414e-02 -7.111055e-02 -1.528381e-02 -2.294757e-02 [51] 1.937691e-02 -5.292572e-03 3.536920e-03 -5.224231e-03 -3.016135e-02 [56] -5.156729e-02 -2.636848e-02 7.015892e-03 2.314429e-02 -1.007325e-02 [61] -1.574000e-02 > (mypacf <- c(rpacf$acf)) [1] 0.518146316 0.100890631 -0.232172573 -0.050259819 -0.097541055 [6] -0.132960367 -0.033252468 0.009441728 -0.120083264 -0.007594263 [11] 0.012595669 -0.069241679 -0.118810081 -0.051766185 0.058288953 [16] -0.058566729 -0.046923864 -0.045837288 0.010082243 -0.065980464 [21] 0.047691138 -0.038069604 -0.064348078 -0.167134257 0.080389045 [26] -0.217493487 -0.077713750 0.065837705 -0.121126963 -0.085221836 [31] -0.011498422 -0.009994257 0.078835640 -0.113378076 -0.140857854 [36] -0.008238271 -0.059929999 -0.020674736 -0.110431373 -0.048597163 [41] 0.010833395 0.079913570 -0.016951742 -0.039469442 -0.087556840 [46] -0.044715428 -0.037257966 0.041455791 -0.001420768 -0.033245187 [51] 0.018586380 -0.060537236 -0.065935125 -0.035451652 -0.076480521 [56] 0.031686011 0.097758347 -0.068891478 -0.061730335 0.012404992 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/4uuav1384527371.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/fisher/rcomp/tmp/5s9oj1384527371.tab") > > try(system("convert tmp/1det01384527371.ps tmp/1det01384527371.png",intern=TRUE)) character(0) > try(system("convert tmp/207sa1384527371.ps tmp/207sa1384527371.png",intern=TRUE)) character(0) > try(system("convert tmp/31h4j1384527371.ps tmp/31h4j1384527371.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.787 0.415 2.186