R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree" 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(99.1,98.9,98.8,98.8,99.2,99.6,100.5,100.6,100.7,101,101.3,101.5,102.3,103,102.9,103.5,103.8,103.6,103.4,103.4,103.3,103.2,103.2,103.5,104.5,105.7,106.5,107,106.7,107.1,106.1,106.2,106.5,106.8,107,107.2,107.8,107.9,107.9,108.2,108.9,109.1,109.3,109.8,109.8,109.9,109.9,109.9,108.8,108.5,108.8,108.8,108.8,108.9,108.8,108.4,107.7,107.3,107,107.7) > 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.327 (Mon, 30 Nov 2015 06:58:35 +0000) > #Author: root > #To cite this work: Wessa P., (2015), (Partial) Autocorrelation Function (v1.0.12) 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) > x <- na.omit(x) > 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/1vd961452281547.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/2wf5z1452281547.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/3nx3x1452281547.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.95973899 0.91249851 0.85876529 0.80137223 0.74459266 [7] 0.69183356 0.64698437 0.60017708 0.55198995 0.50274840 0.45381676 [13] 0.40342359 0.35470608 0.31044503 0.26268967 0.22030503 0.17824650 [19] 0.13439398 0.08594624 0.03475010 -0.01783221 -0.07165700 -0.12362230 [25] -0.17134596 -0.20617709 -0.23004141 -0.24795673 -0.26371532 -0.28394375 [31] -0.29995802 -0.32924235 -0.35547189 -0.37868257 -0.39678102 -0.41241846 [37] -0.42337193 -0.42548152 -0.42649371 -0.42781582 -0.42641630 -0.41861560 [43] -0.40809467 -0.39386601 -0.37384262 -0.35175054 -0.32559080 -0.29985297 [49] -0.27250005 > (mypacf <- c(rpacf$acf)) [1] 0.959738987 -0.109002452 -0.100575638 -0.063914877 -0.012320028 [6] 0.023493022 0.063639159 -0.075880902 -0.061539133 -0.044207903 [11] -0.015893614 -0.040686058 -0.006220788 0.010920724 -0.095265730 [16] 0.030043817 -0.035532317 -0.066034041 -0.093967734 -0.065394265 [21] -0.061831545 -0.044762596 -0.030112592 -0.014458281 0.092821734 [26] 0.076567616 -0.001302754 -0.046522800 -0.100643129 0.031260740 [31] -0.186229816 0.022222271 -0.006275510 0.005096625 -0.040559317 [36] 0.013290961 0.051414608 -0.002952898 -0.042375912 0.010344784 [41] 0.050225526 0.004060648 0.001990883 -0.018374831 0.004734902 [46] 0.014871003 -0.013086119 0.019213291 > 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/4smx61452281547.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/5hjig1452281547.tab") > > try(system("convert tmp/1vd961452281547.ps tmp/1vd961452281547.png",intern=TRUE)) character(0) > try(system("convert tmp/2wf5z1452281547.ps tmp/2wf5z1452281547.png",intern=TRUE)) character(0) > try(system("convert tmp/3nx3x1452281547.ps tmp/3nx3x1452281547.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.346 0.285 1.649