R version 3.2.2 (2015-08-14) -- "Fire Safety" Copyright (C) 2015 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(79.21,79.08,79.88,80.57,80.9,80.89,80.61,80.98,81.68,83.28,83.94,89.25,95.3,97.68,98.53,98.32,97.02,90.13,88.49,88.07,87.17,86.1,86.59,85.89,85.82,86.68,86.3,86.32,85.61,85.52,85.97,86.6,86.78,84.98,85.21,86.39,88.39,88.83,95.76,100.98,102.56,102.92,104.35,105.07,105.41,105.06,104.33,104.61,104.78,104.38,104.08,103.4,101.72,100.1,100.37,96.27,95.28,95.85,96.76,97,96.71,96.97,96.97,98.01,99.18,99.51,99.16,99.4,97.59,96.71,96.56,96.42) > 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/1yb3s1445624456.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/2hzbr1445624456.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/3z0kv1445624456.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.951425299 0.872866792 0.781183131 0.680402763 [6] 0.575619232 0.481295385 0.395885039 0.315788477 0.244759369 [11] 0.181826242 0.124048599 0.084741245 0.067162952 0.059838558 [16] 0.062005584 0.070858506 0.078347043 0.072202843 0.066663674 [21] 0.062745586 0.058524616 0.065226263 0.081645346 0.095505712 [26] 0.105521938 0.111317310 0.102625808 0.076745657 0.038593938 [31] -0.005736238 -0.048242486 -0.090927454 -0.134802364 -0.181039191 [36] -0.223848511 -0.268526338 -0.311360877 -0.353184546 -0.379216374 [41] -0.391620337 -0.395292792 -0.391111732 -0.377556915 -0.355135167 [46] -0.325026019 -0.295075844 -0.265804114 -0.233617464 > (mypacf <- c(rpacf$acf)) [1] 0.951425299 -0.341210483 -0.095665429 -0.104123981 -0.061646417 [6] 0.080789109 -0.022803963 -0.052950279 0.004729919 -0.028846766 [11] -0.031778266 0.145526119 0.100951184 -0.034703222 0.023598309 [16] -0.021792776 -0.045840222 -0.125195032 0.086813339 0.028095796 [21] 0.011868109 0.130158284 0.025883844 -0.051990455 -0.006984537 [26] -0.036713903 -0.113928844 -0.091662972 -0.116096343 -0.040322147 [31] 0.087067082 -0.067147340 -0.041858847 -0.020850720 0.013967438 [36] -0.123425849 -0.017858317 -0.104158298 0.033944814 -0.011177522 [41] -0.043240090 -0.003021884 0.050502458 0.087966920 0.052922144 [46] -0.053902334 -0.040942899 -0.031359973 > 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/4rwo31445624456.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/55wd41445624456.tab") > > try(system("convert tmp/1yb3s1445624456.ps tmp/1yb3s1445624456.png",intern=TRUE)) character(0) > try(system("convert tmp/2hzbr1445624456.ps tmp/2hzbr1445624456.png",intern=TRUE)) character(0) > try(system("convert tmp/3z0kv1445624456.ps tmp/3z0kv1445624456.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.155 0.229 1.390