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(209305,161498,126542,100278,168677,143277,127573,90760,160404,132039,117053,101248,152336,135356,119590,81695,155847,129364,111902,86772,150695,123177,114397,76927,160032,126833,110054,87080,161472,133737,121069,89365,163837,136276,120950,78858,124634,96579,94974,71028,145065,125041,120555,92507,180404,147940,125532,101901,166452,164909,95859,75225,115418,95535,90178,115685,107032,91924,85095,103517,109702,91594,99712,148342) > 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/105871476869795.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/25g4x1476869795.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/34f0m1476869795.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.07785292 -0.13449838 -0.05384230 0.66659638 -0.11084664 [7] -0.24073971 -0.17727733 0.48651423 -0.22891512 -0.27326275 -0.14524230 [13] 0.41075830 -0.18311436 -0.17063709 -0.05782054 0.47572025 -0.10261024 [19] -0.16084339 -0.04145220 0.42209675 -0.08374500 -0.15441825 -0.06504223 [25] 0.34550570 -0.11014751 -0.19291859 -0.07420752 0.27524835 -0.09605529 [31] -0.13827157 -0.02968764 0.23649524 -0.07084048 -0.12964612 -0.03589595 [37] 0.15055849 -0.11916797 -0.12900514 -0.01335580 0.15318434 -0.03510818 [43] -0.07767630 0.03767345 0.16575004 -0.00965524 -0.06884498 0.01695732 [49] 0.06244938 > (mypacf <- c(rpacf$acf)) [1] 0.0778529219 -0.1414165973 -0.0317030528 0.6730840953 -0.4660757953 [6] -0.0216264896 -0.0790897355 0.0851336534 -0.2357668083 0.0296332675 [11] 0.0995649826 -0.1240266260 0.1435384883 0.0035104636 0.0189355120 [16] 0.1903579253 -0.0696417743 -0.1256181271 0.0649043103 0.0002347518 [21] 0.0362278495 -0.0070023493 0.0506852351 -0.0628107672 -0.0011622986 [26] 0.0170138802 -0.0504611515 -0.0106178399 0.0830292918 0.0175023430 [31] -0.0119287010 -0.0516806320 0.0547827142 -0.0667503625 -0.0721560163 [36] -0.0651906740 -0.1100823251 0.0811717377 0.0353493161 0.0755002976 [41] 0.1130619945 -0.0319411370 0.0653431459 -0.0560806173 -0.0410867715 [46] -0.0267179266 -0.0820465498 -0.0866260602 > 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/4p2141476869795.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/5g7ig1476869795.tab") > > try(system("convert tmp/105871476869795.ps tmp/105871476869795.png",intern=TRUE)) character(0) > try(system("convert tmp/25g4x1476869795.ps tmp/25g4x1476869795.png",intern=TRUE)) character(0) > try(system("convert tmp/34f0m1476869795.ps tmp/34f0m1476869795.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.172 0.108 1.292