R version 3.0.3 (2014-03-06) -- "Warm Puppy" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: i686-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(55.64,56.13,56.69,56.8,56.93,57,57.01,57.21,57.17,57.36,57.29,57.26,57.29,57.68,58.19,58.34,58.46,58.67,58.72,58.74,58.77,58.84,59.13,59.12,59.12,59.33,59.49,59.67,59.7,59.73,59.74,59.62,59.6,59.98,60.05,60.06,60.1,60.18,60.38,60.52,60.78,60.72,60.72,60.86,60.99,61.11,61.17,61.19,61.19,61.22,61.19,60.82,60.6,60.15,60.14,60.2,60.36,60.38,60.44,60.47) > 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/1rrcd1395094111.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/2ptas1395094111.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/39g0m1395094111.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.93790806 0.88106545 0.83544783 0.79046539 0.74807127 [7] 0.70504976 0.65984156 0.61331569 0.56138238 0.51007422 0.45422632 [13] 0.39297291 0.32641551 0.26646183 0.21938317 0.17570486 0.13388559 [19] 0.09775558 0.06143071 0.02274679 -0.01591866 -0.05445714 -0.08537328 [25] -0.11865584 -0.15443305 -0.18648649 -0.21519575 -0.23602371 -0.25617017 [31] -0.27705290 -0.29838862 -0.32508111 -0.35427073 -0.37269316 -0.38815355 [37] -0.40183606 -0.41504234 -0.42589627 -0.42837385 -0.42534351 -0.41419351 [43] -0.40590115 -0.39902232 -0.38819281 -0.37274737 -0.35305045 -0.32651717 [49] -0.29576416 > (mypacf <- c(rpacf$acf)) [1] 0.937908058 0.011584327 0.064808166 -0.012184185 0.005325510 [6] -0.025892855 -0.039165086 -0.039655287 -0.077350154 -0.034383825 [11] -0.081700488 -0.089444656 -0.104583311 -0.009956857 0.054525455 [16] 0.006018411 0.003869587 0.029994044 -0.010432276 -0.037079317 [21] -0.033128381 -0.043062756 0.017603014 -0.060422131 -0.071126167 [26] -0.043171215 -0.032488672 0.027168858 -0.018708321 -0.023217761 [31] -0.028880131 -0.066224163 -0.072376108 0.024717019 -0.019666399 [36] -0.012210061 -0.027113184 -0.026401799 0.025546011 0.025559875 [41] 0.068814045 -0.019191302 -0.007282630 0.010829162 0.018096289 [46] -0.002765548 0.032299501 0.043094574 > 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/46l8d1395094111.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/5xme81395094111.tab") > > try(system("convert tmp/1rrcd1395094111.ps tmp/1rrcd1395094111.png",intern=TRUE)) character(0) > try(system("convert tmp/2ptas1395094111.ps tmp/2ptas1395094111.png",intern=TRUE)) character(0) > try(system("convert tmp/39g0m1395094111.ps tmp/39g0m1395094111.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.256 0.442 2.702