R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-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(27.88,28.06,28.08,28.12,28.11,28.18,28.2,28.37,28.64,28.75,28.97,29.08,29.16,29.24,29.36,29.35,29.43,29.49,29.61,29.66,29.75,29.74,29.97,30.02,30.09,30.16,30.33,30.41,30.44,30.45,30.46,30.51,30.54,30.82,30.88,30.89,31.13,31.41,31.47,31.56,31.62,31.65,31.79,31.98,32.14,32.32,32.5,32.55,32.66,32.68,32.72,32.8,32.93,32.96,32.98,33.09,33.46,33.65,33.82,33.83,33.92,33.87,34.03,34.11,34.29,34.44,34.64,34.77,35.01,35.19,35.32,35.35) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/1yy8c1413823444.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/2nk9x1413823444.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/3ujuw1413823444.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.0000000000 0.1616720837 0.0636362606 -0.1493477984 -0.0228633096 [6] -0.3256098359 -0.0083772505 -0.1548641459 -0.0376053074 0.0224077001 [11] 0.1766119437 0.1600860112 0.1674132216 0.0215369940 -0.0026907728 [16] -0.0829858386 -0.2031797733 -0.1093403324 -0.1045585226 0.1370425638 [21] 0.0778355140 -0.0208423663 -0.0552089317 0.1502229255 -0.0218520944 [26] 0.0653812900 0.0770402472 -0.1041177437 -0.0892855966 0.0907750088 [31] 0.0450112126 -0.0199286957 0.0807650639 -0.0416917662 0.0003607578 [36] 0.0079419376 0.1005971394 -0.0751789843 0.0067866765 -0.1525442190 [41] -0.0666406066 -0.1668337422 -0.0002677550 -0.0604963893 0.0327437981 [46] -0.0323216680 0.0936063711 0.0171351133 0.1214129795 > (mypacf <- c(rpacf$acf)) [1] 0.161672084 0.038504832 -0.170158276 0.026165574 -0.323743115 [6] 0.086411293 -0.163354119 -0.093794507 0.093024543 0.004253674 [11] 0.179961418 0.036512527 -0.018838722 0.071684907 -0.056989771 [16] -0.126627973 0.036378833 -0.115519430 0.244521405 -0.035155371 [21] -0.241488795 0.065629961 0.003624000 -0.014663421 0.119277536 [26] 0.039276046 -0.081325678 0.116018457 0.014338494 0.058801668 [31] -0.006777999 0.048818714 -0.010891524 -0.014372100 0.069222272 [36] 0.104079850 -0.148750005 -0.019557384 -0.147702780 -0.118742956 [41] 0.005694441 -0.152949029 -0.075272816 -0.031746119 -0.163613818 [46] 0.089509100 0.029099123 -0.002058817 > 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/4nqox1413823444.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/5wgo91413823444.tab") > > try(system("convert tmp/1yy8c1413823444.ps tmp/1yy8c1413823444.png",intern=TRUE)) character(0) > try(system("convert tmp/2nk9x1413823444.ps tmp/2nk9x1413823444.png",intern=TRUE)) character(0) > try(system("convert tmp/3ujuw1413823444.ps tmp/3ujuw1413823444.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.149 0.235 1.392