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(126.81,125.8,123.07,119.52,118.03,117.27,117.27,116.69,115.38,114.31,113.33,111.79,111.79,110.92,109.37,107.04,104.72,104.14,104.14,102.95,102.13,101.01,100.07,99.4,99.4,99.34,97.72,96.26,95.77,95.04,95.04,94.55,94,93.14,91.21,90.3,90.3,89.74,89.07,89.06,88.97,88.78,88.78,88.23,87.91,87.79,87.89,88,88,87.08,85.75,84.29,84.39,83.72,83.72,81.76,81.53,80.55,79.83,78.98,78.98,78.27,77.41,76.75,76.38,74.96,74.96,74.46,74.04,73.22,72.97,72.91,72.91,73.27,72.93,72.67,71.94,71.9,71.89,71.72,70.85,69.82,69.61,69.48) > 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/1jj5s1384333870.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/2hh781384333870.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/3krrc1384333870.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.95506721 0.90927805 0.86644711 0.82942496 0.79415792 [7] 0.75841334 0.72037638 0.68131700 0.64347858 0.60650833 0.57009063 [13] 0.53410930 0.49586180 0.45727239 0.42007459 0.38651366 0.35607956 [19] 0.32570642 0.29365471 0.26368179 0.23436682 0.20659753 0.18034211 [25] 0.15465193 0.12739562 0.09989443 0.07494829 0.05266440 0.03049160 [31] 0.01059717 -0.01052725 -0.03133751 -0.05238992 -0.07125330 -0.08627639 [37] -0.09978135 -0.11429506 -0.12859903 -0.14253032 -0.15711746 -0.17214690 [43] -0.18718617 -0.20325811 -0.21894803 -0.23465423 -0.25079904 -0.26744899 [49] -0.28490366 -0.30359766 -0.32066021 -0.33414240 -0.34480799 -0.35592037 [55] -0.36622221 -0.37751781 -0.38536534 -0.39289674 -0.39762164 -0.39985705 [61] -0.40112483 > (mypacf <- c(rpacf$acf)) [1] 0.9550672117 -0.0327312528 0.0098170896 0.0425780189 -0.0006263886 [6] -0.0216532950 -0.0412805252 -0.0310687334 -0.0104055974 -0.0169094039 [11] -0.0182629091 -0.0166071450 -0.0473222940 -0.0273018736 -0.0113653457 [16] 0.0117747792 0.0100552951 -0.0191455834 -0.0345295239 0.0055981427 [21] -0.0177041975 -0.0093536139 -0.0059851674 -0.0147453961 -0.0364619249 [26] -0.0246004268 0.0029980344 0.0018973513 -0.0244268538 0.0075113749 [31] -0.0290788624 -0.0156781827 -0.0253305731 -0.0022896025 0.0201059465 [36] -0.0024992218 -0.0253187931 -0.0099619476 -0.0142999163 -0.0331652985 [41] -0.0299824851 -0.0232253261 -0.0319143472 -0.0199996282 -0.0261892434 [46] -0.0312781307 -0.0339473315 -0.0393703680 -0.0396274601 -0.0093596146 [51] 0.0112976763 0.0025031259 -0.0276931756 -0.0085391054 -0.0321395980 [56] 0.0122656314 -0.0236668473 0.0050473050 0.0066708248 -0.0098982699 > 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/4r1nz1384333870.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/5wca21384333870.tab") > > try(system("convert tmp/1jj5s1384333870.ps tmp/1jj5s1384333870.png",intern=TRUE)) character(0) > try(system("convert tmp/2hh781384333870.ps tmp/2hh781384333870.png",intern=TRUE)) character(0) > try(system("convert tmp/3krrc1384333870.ps tmp/3krrc1384333870.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.997 0.402 2.376