R version 3.3.1 (2016-06-21) -- "Bug in Your Hair" Copyright (C) 2016 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(106,106.8,106.5,107.6,107.6,107.6,108.9,108.5,108.9,108.7,108.4,108.4,109.2,109.3,109.4,109.3,109,108.8,108.7,106.1,106.2,109.7,108.4,108.3,108.1,110.6,111.8,111.7,112.2,111.1,111,111,113.6,114,116.1,115.5,115.8,115.6,114.1,114.2,113.4,112,110.9,111,112.8,113.8,114.7,113.9,114.5,113.8,113.8,113.7,113,113.1,112.4,112.8,113.2,112.9,113.9,113.2) > 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/1v5hv1476791228.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/2q1my1476791228.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/37xhf1476791228.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.900962256 0.808105665 0.716064309 0.646474899 [6] 0.584085240 0.520033002 0.493706313 0.460731095 0.444433394 [11] 0.419810314 0.398382167 0.346651206 0.285754657 0.222444514 [16] 0.164371850 0.134275818 0.124810388 0.138255363 0.137468522 [21] 0.081324236 0.015616554 -0.008537365 -0.064783333 -0.138862775 [26] -0.226483670 -0.288279297 -0.318997904 -0.341637307 -0.348462590 [31] -0.359421130 -0.380654834 -0.413874444 -0.418318245 -0.426945250 [36] -0.401316357 -0.370623021 -0.330241419 -0.293925285 -0.278733889 [41] -0.238885668 -0.211993786 -0.211046693 -0.225366068 -0.243201475 [46] -0.242900147 -0.235618487 -0.213173824 -0.200517326 > (mypacf <- c(rpacf$acf)) [1] 0.9009622560 -0.0192668986 -0.0461077651 0.0661809014 0.0015223222 [6] -0.0470028439 0.1712523064 -0.0415078065 0.0640958164 -0.0135043145 [11] 0.0054736134 -0.1702866275 -0.0487490354 -0.0700560092 -0.0174217489 [16] 0.0825483360 0.1083740329 0.0641224079 -0.0479741925 -0.3405175275 [21] -0.1156672196 0.2283308593 -0.2124235184 -0.1457700963 -0.0769313350 [26] -0.0532478487 0.0435838293 0.0096696468 -0.1018888402 -0.0245634230 [31] -0.0451309930 -0.0411075445 0.1903602768 0.0001660198 0.1236725562 [36] 0.0574961776 0.0346499911 -0.0239185743 0.0346422533 0.0582246575 [41] -0.1405776297 -0.0680266111 0.2018331288 -0.1131320553 -0.0228049824 [46] -0.0857698598 -0.0065214106 -0.0366695990 > 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/4uhuh1476791228.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/50dre1476791228.tab") > > try(system("convert tmp/1v5hv1476791228.ps tmp/1v5hv1476791228.png",intern=TRUE)) character(0) > try(system("convert tmp/2q1my1476791228.ps tmp/2q1my1476791228.png",intern=TRUE)) character(0) > try(system("convert tmp/37xhf1476791228.ps tmp/37xhf1476791228.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.112 0.095 1.220