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(92.8,90.61,88.49,88.33,87.7,87.33,87.33,87.33,85.47,86.1,86.1,86.13,83.31,83.31,83.55,84.11,84.11,77.59,77.59,76.44,72.71,72.9,72.39,72.46,72.48,72.48,72.48,72.3,72.3,72.3,71.14,71.14,68.99,68.42,68.42,69.28,65.22,70.21,70.21,71.2,68.94,68.94,68.93,68.93,68.93,68.93,59.94,61.04,60.2,60.2,60.12,60.25,58.03,62.37,62.16,62.16,62.16,62.16,62.29,64.39) > 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/1cely1333486122.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/2rzpk1333486122.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/37wrx1333486122.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.936077241 0.883514268 0.833417359 0.782442377 [6] 0.729414239 0.677878492 0.615718465 0.556699694 0.504689129 [11] 0.456544501 0.398277680 0.342045038 0.292239022 0.243072451 [16] 0.202201741 0.157645546 0.098928772 0.069540761 0.038654267 [21] 0.006753141 -0.005836571 -0.019550634 -0.033306585 -0.054963541 [26] -0.074245015 -0.092136295 -0.116030645 -0.137584254 -0.159831826 [31] -0.191285099 -0.216698235 -0.242290098 -0.262653038 -0.277511370 [36] -0.297014286 -0.321348140 -0.324933258 -0.344791773 -0.367829102 [41] -0.393761119 -0.406701133 -0.416019255 -0.423948464 -0.421357071 [46] -0.423737215 -0.428789232 -0.402290894 -0.379084938 > (mypacf <- c(rpacf$acf)) [1] 0.9360772414 0.0587726366 -0.0002334097 -0.0304112969 -0.0456026307 [6] -0.0216364259 -0.1161338591 -0.0270035933 0.0188300643 0.0082387593 [11] -0.1051912638 -0.0387435000 0.0152261314 -0.0261524982 0.0263116051 [16] -0.0599460028 -0.1450309288 0.1775288367 -0.0282492033 -0.0402038743 [21] 0.1381305871 -0.0109739234 -0.0019365143 -0.1293543116 -0.0459819572 [26] 0.0122022199 -0.0733288829 -0.0539365148 -0.0351434599 -0.0757384788 [31] -0.0279137749 -0.0251510608 0.0200591093 -0.0061393538 -0.0054403360 [36] -0.1030679019 0.1023457274 -0.0999971454 -0.0981295765 -0.0395106780 [41] 0.0365224051 0.0246749482 -0.0348932581 0.0135196293 -0.0289601768 [46] -0.0390000232 0.1733334675 -0.0164776598 > 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/4crpj1333486122.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/5sseo1333486122.tab") > > try(system("convert tmp/1cely1333486122.ps tmp/1cely1333486122.png",intern=TRUE)) character(0) > try(system("convert tmp/2rzpk1333486122.ps tmp/2rzpk1333486122.png",intern=TRUE)) character(0) > try(system("convert tmp/37wrx1333486122.ps tmp/37wrx1333486122.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.981 0.232 1.210