R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(402.55,403.04,399.25,401.26,402.76,402.27,402.27,406.11,406.39,407.88,407.77,407.77,407.77,408.06,403.74,403.44,404.3,403.29,403.29,400.66,400.84,401.31,402,402,402,403.33,403.79,403.04,402.91,406.55,406.55,404.69,404.74,404.2,404.18,404.18,404.18,404.82,406.46,407.25,407.34,404.3,404.3,404.7,406.82,406.82,406.76,406.76,406.76,407.67,406.03,401.97,401.84,402.24,402.24,401.57,401.63,402.06,402.11,402.43) > 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/16k321337688624.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/2yhmk1337688624.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/3ltqd1337688624.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.000000000 0.785977738 0.568043912 0.402202113 0.248183384 [6] 0.053131627 -0.129744669 -0.288856836 -0.317676222 -0.324820024 [11] -0.358051889 -0.375039520 -0.327073308 -0.247368287 -0.164463259 [16] -0.120606227 -0.056317143 0.022531679 0.031045124 0.027868822 [21] 0.016970995 -0.014833805 -0.035073165 -0.092467483 -0.135278769 [26] -0.141176274 -0.116918521 -0.081705677 -0.032798771 0.010952512 [31] 0.074769637 0.177874158 0.205612579 0.206173587 0.200953355 [36] 0.214188632 0.224198699 0.202927636 0.122215022 0.070288510 [41] -0.007509959 -0.096131381 -0.199789895 -0.264651267 -0.294251440 [46] -0.266750446 -0.239054010 -0.193691866 -0.107473713 > (mypacf <- c(rpacf$acf)) [1] 0.7859777384 -0.1300680817 -0.0002890562 -0.0933411897 -0.2248904311 [6] -0.1393208570 -0.1621655563 0.1516303243 -0.0534372926 -0.1266405549 [11] -0.0783260606 -0.0208249626 0.0112886792 -0.0006962315 -0.0542742293 [16] 0.0259664754 -0.0231798391 -0.1903748015 0.0105102149 -0.0593966715 [21] -0.0918544199 -0.0256678835 -0.1704754145 -0.0018508663 -0.0747067319 [26] 0.0039262210 0.0411680912 -0.0226449601 -0.0346531778 -0.0200905746 [31] 0.1358167388 -0.1177544113 -0.0127181089 -0.0472099494 0.0856891777 [36] 0.0487433964 0.0048910837 -0.0385302491 -0.0209047262 -0.1215078783 [41] -0.0875547131 -0.0520436629 0.0013961404 -0.0405919223 0.0095274694 [46] -0.0093697702 -0.0207747105 0.0122020238 > 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/4x9mj1337688624.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/51c8z1337688624.tab") > > try(system("convert tmp/16k321337688624.ps tmp/16k321337688624.png",intern=TRUE)) character(0) > try(system("convert tmp/2yhmk1337688624.ps tmp/2yhmk1337688624.png",intern=TRUE)) character(0) > try(system("convert tmp/3ltqd1337688624.ps tmp/3ltqd1337688624.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.045 0.232 1.272