R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(67.22,67.31,67.14,67.22,67.17,67.27,67.27,67.27,67.48,67.38,67.22,67.2,67.2,67.19,67.32,67.61,67.85,67.74,67.74,67.61,67.85,67.89,67.97,67.94,67.94,68.07,67.85,67.84,67.89,67.86,67.86,67.89,67.7,68.05,68.18,68.19,68.19,68.27,68.22,68.14,68.36,68.34,68.34,68.24,68.14,68.23,68.09,68.03,68.03,67.89,67.63,67.61,67.41,67.29,67.29,67.49,67.68,68.05,67.7,67.86) > 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/wessaorg/rcomp/tmp/1dmbu1333537857.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/2xq6p1333537857.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/3dg3r1333537857.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.057614159 0.058612752 -0.034595701 -0.047986440 [6] -0.053329762 -0.011886342 -0.023288672 0.075897448 0.015660166 [11] -0.150710333 -0.095262422 0.012898042 -0.084352467 -0.059996048 [16] 0.099663267 -0.150845624 0.110092090 -0.086384530 0.022395699 [21] 0.128222535 -0.031073684 0.103328891 -0.020462738 0.029961823 [26] -0.067546922 0.137901532 -0.060829887 -0.042175024 -0.047722215 [31] -0.076524146 -0.145981776 0.087659142 -0.057345811 -0.022859785 [36] 0.002961778 -0.066576041 0.036245755 -0.229333185 0.103569181 [41] 0.085744955 0.163893079 0.022425946 -0.012212096 -0.018546224 [46] -0.042920105 -0.048634469 -0.033460342 0.069808608 0.046992293 [51] -0.040151715 0.032403583 0.022532994 -0.062803369 0.034210859 [56] -0.068000480 0.083396675 -0.044533509 0.009466927 > (mypacf <- c(rpacf$acf)) [1] -0.057614159 0.055477512 -0.028391162 -0.055006820 -0.055876171 [6] -0.013271195 -0.022173893 0.069424400 0.020310156 -0.165587651 [11] -0.119895317 0.026226950 -0.071750289 -0.098294218 0.080767259 [16] -0.168339280 0.055641444 -0.053493880 0.010458841 0.113692447 [21] -0.065468529 0.108407166 -0.048909111 0.010842001 -0.041524555 [26] 0.128696050 -0.060809287 -0.081319836 -0.060028621 -0.077408624 [31] -0.117434008 0.047939211 0.031804377 -0.137941597 -0.016022611 [36] -0.006532302 0.001117582 -0.260096201 0.077019891 0.123290777 [41] 0.015820430 0.030487756 -0.062546301 -0.059156274 -0.081404088 [46] -0.007621720 -0.072208195 -0.026389847 -0.016662526 0.015569853 [51] 0.094513288 -0.050770372 0.060878501 -0.032565673 -0.007323873 [56] 0.034296702 -0.012078461 0.009490814 > 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/4l98u1333537857.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/5vf181333537857.tab") > > try(system("convert tmp/1dmbu1333537857.ps tmp/1dmbu1333537857.png",intern=TRUE)) character(0) > try(system("convert tmp/2xq6p1333537857.ps tmp/2xq6p1333537857.png",intern=TRUE)) character(0) > try(system("convert tmp/3dg3r1333537857.ps tmp/3dg3r1333537857.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.952 0.207 1.157