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.94,1.82,1.8,1.79,1.79,1.78,1.81,1.84,1.87,1.87,1.87,1.84,1.82,1.83,1.83,1.82,1.83,1.87,1.88,1.9,1.98,2.03,2.14,2.42,2.73,2.84,2.85,2.94,3.06,3.24,3.18,3.01,2.87,2.73,2.63,2.39,2.26,2.11,2.01,1.99,1.96,1.93,1.98,2.07,2.24,2.31,2.23,2.26,2.28,2.3,2.33,2.26,2.24,2.47,2.55,2.89,3.21,3.21,2.92,2.68,2.4,2.28,2.24,2.2,2.18,2.23,2.24,2.25,2.23,2.25,2.23,2.21,2.17,2.17,2.13,2.12,2.13,2.17,2.33,2.5,2.57,2.59,2.58,2.31) > 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/wessaorg/rcomp/tmp/1w4ed1387830728.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/2r2rw1387830728.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/340781387830728.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.63020034 0.30479498 0.08051051 -0.07940183 -0.12077103 [7] -0.11099583 -0.20575203 -0.18149004 -0.13866729 -0.12227164 -0.08213009 [13] -0.08237166 -0.10874052 -0.12144304 -0.13630309 -0.14400787 -0.18049276 [19] -0.23928521 -0.18035702 -0.10263408 -0.03888641 0.03643591 0.16396822 [25] 0.20702495 0.24578286 0.20764082 0.10808337 0.05700229 0.08953681 [31] 0.03570463 0.10048041 0.14038697 0.07022347 -0.01463245 -0.06516048 [37] -0.07054972 -0.05495833 -0.08700865 -0.08641761 -0.07094473 -0.07628535 [43] -0.06440935 -0.09160880 -0.08681312 -0.03712378 -0.02192540 -0.01566605 [49] 0.02627748 0.03905599 0.05887025 0.03721654 0.01104217 0.01066182 [55] -0.03005506 0.02736490 0.06178547 0.07883648 0.03186684 -0.02101420 [61] -0.04042328 > (mypacf <- c(rpacf$acf)) [1] 6.302003e-01 -1.532021e-01 -7.550683e-02 -1.015256e-01 1.552149e-02 [6] -1.613822e-02 -2.232412e-01 6.723578e-02 -3.409339e-02 -6.066736e-02 [11] -2.490228e-02 -8.051353e-02 -4.784324e-02 -1.021690e-01 -6.932743e-02 [16] -7.058367e-02 -1.744788e-01 -1.717040e-01 9.401325e-03 -7.797352e-02 [21] -9.649527e-02 -5.064122e-02 1.308577e-01 -5.916502e-02 -1.217179e-02 [26] -4.100735e-02 -8.150612e-02 -1.543306e-02 6.621355e-02 -1.015110e-01 [31] 1.502111e-01 2.952130e-02 -8.098886e-02 -9.701478e-02 -3.916530e-02 [36] 7.681481e-02 -7.571803e-02 -7.225000e-02 7.598701e-02 -5.462549e-03 [41] -8.950801e-03 -1.691919e-02 -3.785950e-02 4.135117e-02 -6.211550e-03 [46] -1.877513e-02 3.390025e-03 -1.821037e-02 6.579274e-02 4.170768e-02 [51] -8.452348e-02 -4.865199e-02 5.115338e-02 -1.341198e-01 8.927420e-02 [56] -7.152436e-02 5.798869e-02 -1.143766e-01 5.052503e-03 -3.358537e-05 > 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/42x381387830729.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/5kwar1387830729.tab") > > try(system("convert tmp/1w4ed1387830728.ps tmp/1w4ed1387830728.png",intern=TRUE)) character(0) > try(system("convert tmp/2r2rw1387830728.ps tmp/2r2rw1387830728.png",intern=TRUE)) character(0) > try(system("convert tmp/340781387830728.ps tmp/340781387830728.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.772 0.609 3.352