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(8378669.00,7557530.00,8656721.00,7729873.00,7067002.00,7222189.00,6758161.00,6745665.00,8203660.00,8799755.00,7995151.00,6844694.00,7400186.00,6146183.00,6793027.00,5815146.00,5993505.00,5838016.00,5926815.00,5642890.00,7120621.00,7781743.00,7638921.00,5886070.00,7358890.00,6981189.00,8423532.00,6819313.00,6727221.00,6923349.00,7578240.00,7228898.00,8988846.00,8404694.00,9601659.00,8213138.00,8434646.00,8466539.00,9106270.00,8438555.00,7723821.00,7538413.00,7199881.00,8168314.00,9045790.00,8544483.00,9020709.00,7932021.00,8435986.00,7920357.00,8333659.00,7415547.00,7770392.00,8188878.00,8092465.00,7188528.00,8152373.00,9025069.00,9233973.00,6916290.00,8171721.00,7012501.00,8779456.00,7308709.00,8084547.00,8255978.00,7658071.00,7371877.00,8780827.00,10116778.00,9567175.00,7455902.00) > 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/17qa81413658532.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/2yz8t1413658532.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/3t2n31413658532.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.36104888 0.11076518 -0.39978942 0.29357398 -0.16365210 [7] 0.13933067 -0.19319970 0.23342009 -0.28832973 0.14977198 -0.25708035 [13] 0.55325398 -0.20816901 0.12760836 -0.29628462 0.16444144 -0.13255898 [19] 0.11228228 -0.10860051 0.12286529 -0.23667880 0.13798053 -0.15244886 [25] 0.34207744 -0.16422429 0.16540713 -0.23203540 0.11789378 -0.19095321 [31] 0.13380555 -0.10819759 0.23177097 -0.24501648 0.07649317 -0.14200203 [37] 0.35925801 -0.15645589 0.10400316 -0.17131187 0.07767711 -0.09182979 [43] 0.01360064 -0.05026461 0.18843222 -0.12283497 0.01175788 -0.15600278 [49] 0.27587693 > (mypacf <- c(rpacf$acf)) [1] -0.361048878 -0.022527741 -0.422261242 0.013275153 -0.102924775 [6] -0.092904003 -0.104377334 0.076253432 -0.240040923 -0.110002423 [11] -0.259546969 0.319092396 0.138943121 0.084185715 0.124280960 [16] -0.042609167 -0.035701649 -0.072052399 0.011117707 -0.069829124 [21] -0.137866129 -0.063879122 -0.081856089 -0.034795019 -0.059135293 [26] 0.067753883 -0.006189877 0.014227610 -0.103185908 -0.062629837 [31] -0.110919288 0.131218678 0.039294037 -0.079697989 -0.017166831 [36] 0.095394998 0.017691170 -0.061814706 0.088266596 -0.099733906 [41] 0.087112117 -0.124912528 -0.028229554 -0.010968094 0.003544178 [46] 0.011416551 -0.095273850 -0.011838481 > 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/4htgx1413658532.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/5bl511413658532.tab") > > try(system("convert tmp/17qa81413658532.ps tmp/17qa81413658532.png",intern=TRUE)) character(0) > try(system("convert tmp/2yz8t1413658532.ps tmp/2yz8t1413658532.png",intern=TRUE)) character(0) > try(system("convert tmp/3t2n31413658532.ps tmp/3t2n31413658532.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.176 0.208 1.399