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(16.41,16.38,16.12,16.03,16.02,16.01,16.01,15.94,15.88,15.75,15.8,15.84,15.84,15.79,15.79,15.75,15.63,15.63,15.63,15.62,15.59,15.55,15.61,15.58,15.58,15.64,15.56,15.57,15.46,15.5,15.5,15.58,15.69,15.78,15.8,15.79,15.79,15.79,15.75,15.71,15.76,15.76,15.76,15.76,15.78,15.84,15.82,15.86,15.86,15.87,15.84,15.84,15.89,15.89,15.89,15.91,15.95,16.08,16.08,16.09) > 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/1q4x31333528472.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/25wwm1333528472.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/380nc1333528472.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.84985836 0.68420015 0.57599557 0.51035569 0.45021882 [7] 0.38588825 0.32146758 0.25062498 0.19897012 0.18710066 0.15018308 [13] 0.09025192 0.01401441 -0.05408345 -0.13967084 -0.20970263 -0.23433489 [19] -0.25234550 -0.26904981 -0.28806793 -0.29122715 -0.29524223 -0.32256068 [25] -0.34073946 -0.35927861 -0.40031482 -0.42858822 -0.44352526 -0.40679847 [31] -0.34784038 -0.27735073 -0.20305627 -0.17029045 -0.16000519 -0.16730255 [37] -0.16858940 -0.16613749 -0.16868109 -0.14296635 -0.10761193 -0.08433264 [43] -0.05599176 -0.02161483 0.02285222 0.05061352 0.06155794 0.07692881 [49] 0.07506089 > (mypacf <- c(rpacf$acf)) [1] 0.849858358 -0.137030929 0.114849510 0.062399977 -0.011437120 [6] -0.018326800 -0.023611477 -0.066032997 0.024185607 0.088668586 [11] -0.117997260 -0.055037788 -0.102098441 -0.061008391 -0.169804355 [16] -0.031783033 0.047764593 -0.041859664 0.009328056 -0.048118865 [21] 0.016724341 -0.049924117 -0.106505206 -0.025567633 -0.048113988 [26] -0.129115600 -0.030539331 -0.076548791 0.108089978 0.052672885 [31] 0.048443138 0.078337284 -0.083156229 -0.052637250 -0.135551540 [36] -0.049014219 -0.040388174 -0.045678847 0.054053072 0.022454091 [41] -0.080991977 -0.022570938 -0.050504458 0.010293603 0.011636045 [46] -0.044809246 0.091592346 -0.051113324 > 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/45x1p1333528472.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/55yg91333528472.tab") > > try(system("convert tmp/1q4x31333528472.ps tmp/1q4x31333528472.png",intern=TRUE)) character(0) > try(system("convert tmp/25wwm1333528472.ps tmp/25wwm1333528472.png",intern=TRUE)) character(0) > try(system("convert tmp/380nc1333528472.ps tmp/380nc1333528472.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.951 0.207 1.152