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(92.94,92.97,93.37,92.6,92.84,92.55,92.93,92.44,93.36,93.24,92.65,92.06,92.88,91.69,91.66,90.26,91.11,92.33,91.82,92.24,93.35,93.53,93.34,92.59,92.42,92.64,94.44,93.59,93.39,93.33,93.72,95.43,97.06,97.7,97.59,96.97,97.75,99.27,100.63,99.8,99.5,99.72,99.77,100.18,101.11,100.67,101.13,100.46,101.6,102.3,103.26,104.56,104.61,104.62,105.03,104.93,104.73,104.33,104.6,104.41,104.63,105.55,106.12,106.62,106.72,106.52,106.79,106.95,106.92,106.74,108.13,107.86) > 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/12u831457785227.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/2pow91457785227.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/37yh91457785227.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.96583263 0.92861649 0.89752042 0.86583064 0.83337047 [7] 0.79811904 0.76062490 0.72059758 0.68239598 0.64757581 0.61188483 [13] 0.57702521 0.53795411 0.49423111 0.45005836 0.40075662 0.35192162 [19] 0.30331884 0.25190325 0.20104345 0.14994399 0.10545429 0.06391095 [25] 0.02525851 -0.01211599 -0.05268923 -0.08780306 -0.12550323 -0.15969025 [31] -0.19426527 -0.22986754 -0.26027033 -0.29147918 -0.32388474 -0.35224108 [37] -0.37510642 -0.39324947 -0.41014984 -0.42449023 -0.43757249 -0.44459898 [43] -0.44379294 -0.44291454 -0.44057654 -0.43889876 -0.44147359 -0.43591414 [49] -0.43036517 > (mypacf <- c(rpacf$acf)) [1] 0.965832628 -0.062771259 0.074138387 -0.033987682 -0.019073418 [6] -0.061381316 -0.050225245 -0.064077514 0.003366731 0.019845756 [11] -0.030744144 0.002396251 -0.087427239 -0.087208642 -0.046958922 [16] -0.124162710 -0.026536322 -0.043526717 -0.070863092 -0.022440853 [21] -0.047129331 0.055324089 -0.003611831 0.018253817 -0.021074610 [26] -0.070418943 0.041352569 -0.096755146 0.035805037 -0.067544300 [31] -0.021501390 0.038805681 -0.054622486 -0.051292735 -0.004247742 [36] 0.027536398 0.007032637 -0.008775493 -0.004455706 -0.029580674 [41] 0.075306777 0.048846216 0.001775755 0.015339687 -0.039955094 [46] -0.070329158 0.068493682 -0.049350443 > 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/4rzpi1457785227.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/5xwvl1457785227.tab") > > try(system("convert tmp/12u831457785227.ps tmp/12u831457785227.png",intern=TRUE)) character(0) > try(system("convert tmp/2pow91457785227.ps tmp/2pow91457785227.png",intern=TRUE)) character(0) > try(system("convert tmp/37yh91457785227.ps tmp/37yh91457785227.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.192 0.215 1.418