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(1.8,1.8,1.81,1.81,1.81,1.81,1.81,1.81,1.82,1.82,1.81,1.8,1.8,1.81,1.81,1.81,1.81,1.81,1.81,1.82,1.82,1.82,1.83,1.83,1.83,1.84,1.85,1.86,1.86,1.87,1.87,1.86,1.88,1.89,1.91,1.91,1.91,1.91,1.92,1.93,1.93,1.94,1.94,1.95,1.95,1.96,1.97,1.97,1.97,1.97,1.98,1.98,1.99,1.99,1.99,2,2,2.01,2.01,2.02,2.01,2.01,2.03,2.03,2.04,2.05,2.05,2.06,2.06,2.06,2.04,2.04,2.04,2.03,2.03,2.03,2.03,2.03,2.03,2.03,2.03,2.03,2.02,2.03,2.03,2.02,2.03,2.04,2.05,2.05,2.05,2.05,2.07,2.07,2.08,2.08) > 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/1b0v41413731802.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/2n72r1413731802.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/3ju3m1413731802.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.97440889 0.94801847 0.92368341 0.89832067 0.87504895 [7] 0.84995027 0.82370972 0.79552802 0.77054352 0.74586233 0.72030333 [13] 0.69074783 0.65947954 0.63060915 0.59926593 0.56803690 0.53589437 [19] 0.50318092 0.47023910 0.43779327 0.40466233 0.37027534 0.33764039 [25] 0.30298935 0.26742482 0.23212791 0.19443668 0.15804073 0.12107386 [31] 0.08684745 0.05079406 0.01420543 -0.01800489 -0.04983340 -0.07503914 [37] -0.10092999 -0.12838019 -0.15529871 -0.18080775 -0.20334796 -0.22657329 [43] -0.24625885 -0.26697209 -0.28639003 -0.30424863 -0.32069774 -0.33417802 [49] -0.34777248 > (mypacf <- c(rpacf$acf)) [1] 0.974408888 -0.028780582 0.027404946 -0.034332611 0.030459634 [6] -0.051931970 -0.030934617 -0.057293680 0.051455201 -0.016436946 [11] -0.024605513 -0.099659797 -0.040958473 0.021020554 -0.069577577 [16] -0.022634418 -0.038042812 -0.019126700 -0.030370247 -0.018099370 [21] -0.045857130 -0.035775438 0.009833396 -0.062520675 -0.049657502 [26] -0.024266231 -0.069885395 -0.008478999 -0.047075245 0.023747316 [31] -0.071095666 -0.034726886 0.047283597 -0.023864733 0.103342734 [36] -0.038057773 -0.048098893 -0.011201155 0.003722077 0.013762341 [41] -0.039850034 0.047304048 -0.027418025 -0.008859376 -0.010402170 [46] -0.009504990 0.025648111 -0.003437507 > 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/4ya0e1413731802.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/51dvt1413731802.tab") > > try(system("convert tmp/1b0v41413731802.ps tmp/1b0v41413731802.png",intern=TRUE)) character(0) > try(system("convert tmp/2n72r1413731802.ps tmp/2n72r1413731802.png",intern=TRUE)) character(0) > try(system("convert tmp/3ju3m1413731802.ps tmp/3ju3m1413731802.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.179 0.188 1.380