R version 2.15.3 (2013-03-01) -- "Security Blanket" Copyright (C) 2013 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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.39,2.4,2.42,2.42,2.44,2.44,2.44,2.45,2.46,2.47,2.48,2.48,2.49,2.5,2.51,2.52,2.52,2.52,2.54,2.54,2.54,2.56,2.57,2.58,2.58,2.58,2.58,2.59,2.6,2.61,2.61,2.62,2.63,2.65,2.67,2.68,2.67,2.68,2.68,2.68,2.68,2.69,2.69,2.69,2.7,2.71,2.72,2.71,2.72,2.73,2.74,2.74,2.75,2.75,2.76,2.75,2.78,2.79,2.8,2.81,2.81,2.82,2.82,2.83,2.83,2.84,2.84,2.84,2.86,2.87,2.88,2.88) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '48' > #'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/1d9gu1363277607.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/2sydk1363277607.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/3z5yw1363277607.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.95323757 0.90645686 0.86280309 0.81894818 0.78006711 [7] 0.73906484 0.69586823 0.65413451 0.61223622 0.57216655 0.53222488 [13] 0.49135062 0.45001920 0.41022382 0.37225707 0.33626522 0.30361976 [19] 0.26737191 0.23556760 0.20142267 0.16736916 0.13569286 0.10613777 [25] 0.07833815 0.05048367 0.01917310 -0.01168032 -0.04063197 -0.06738928 [31] -0.09350656 -0.12108675 -0.14676517 -0.17151099 -0.19373331 -0.21321271 [37] -0.23064404 -0.25319552 -0.27318692 -0.29094741 -0.30618440 -0.32074480 [43] -0.33281827 -0.34606206 -0.35840983 -0.36827067 -0.37520572 -0.38113503 [49] -0.39019127 > (mypacf <- c(rpacf$acf)) [1] 0.9532375745 -0.0241411855 0.0097167670 -0.0257067365 0.0315141191 [6] -0.0456127093 -0.0440219251 -0.0110446633 -0.0255552940 -0.0071172136 [11] -0.0262735566 -0.0326603219 -0.0328064207 -0.0105856234 -0.0089630677 [16] -0.0067686860 0.0109977346 -0.0624172521 0.0245980832 -0.0553567408 [21] -0.0216537727 -0.0116101595 0.0012233989 -0.0090545773 -0.0284589524 [26] -0.0602061088 -0.0276644174 -0.0115939967 -0.0084233717 -0.0250962086 [31] -0.0431747491 -0.0063771092 -0.0221127481 -0.0070855266 -0.0006132051 [36] -0.0075732951 -0.0772872357 -0.0023390982 -0.0099355611 -0.0035919977 [41] -0.0304641364 0.0020183556 -0.0362866339 -0.0214372077 -0.0024989075 [46] 0.0034211904 -0.0177641368 -0.0594569402 > 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/4s7t61363277607.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/5ok7a1363277607.tab") > > try(system("convert tmp/1d9gu1363277607.ps tmp/1d9gu1363277607.png",intern=TRUE)) character(0) > try(system("convert tmp/2sydk1363277607.ps tmp/2sydk1363277607.png",intern=TRUE)) character(0) > try(system("convert tmp/3z5yw1363277607.ps tmp/3z5yw1363277607.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.906 0.354 2.257