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(92.1,93.91,95.46,94.54,95.63,96.32,96.42,96.95,96.52,96.82,96.4,96.69,96.72,98.57,98.6,96.44,97.09,97.36,97.74,96.78,96.45,97.66,98.69,98.21,97.33,99.05,100.09,98.1,97.68,97.44,99.19,98.32,97.83,97.71,97.51,97.62,96.49,98.92,99.69,97.06,97.63,97.97,99.01,97.89,97.23,96.93,96.97,97.68,97.73,99.03,100.35,99.38,99.3,99.77,101.11,101.15,101.59,100.95,99.23,100.41) > 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/17s6g1476818011.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/253fo1476818011.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/3gqbj1476818011.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.710826040 0.530365752 0.500778986 0.437354597 [6] 0.341910245 0.202075459 0.193108911 0.180525510 0.118215871 [11] 0.027932457 0.029456392 0.124628142 0.015320661 -0.001871962 [16] 0.069719151 0.094439476 0.073605690 0.001145370 0.036244365 [21] -0.002488141 -0.051706734 -0.117794185 -0.079188702 0.041824756 [26] -0.024131970 -0.038650184 0.026060597 0.075215972 0.070263709 [31] -0.006270723 0.029983213 0.024168722 0.032116258 -0.023141188 [36] -0.055413517 -0.030146485 -0.112428113 -0.121504414 -0.076694837 [41] -0.079127251 -0.075904282 -0.086153492 -0.049339998 -0.076587650 [46] -0.089285810 -0.145173767 -0.212562543 -0.233264658 > (mypacf <- c(rpacf$acf)) [1] 0.710826040 0.050719136 0.216534438 0.003437240 -0.035180046 [6] -0.172852454 0.121552644 -0.011022103 -0.007626818 -0.124974950 [11] 0.084385012 0.164053502 -0.229707146 0.130121078 0.064019537 [16] 0.012678857 -0.043770636 -0.056054922 0.029747884 -0.171699138 [21] 0.030243334 -0.092668765 0.152653981 0.113227024 -0.041307820 [26] 0.007931847 0.029487129 0.050910472 -0.032116387 -0.085797766 [31] -0.015963148 -0.060702591 0.093011584 -0.072297075 -0.025063176 [36] -0.079180801 0.016282092 0.049642695 0.067583965 -0.103984281 [41] 0.039505812 -0.006998925 -0.058577563 -0.081550437 -0.013111306 [46] -0.094977912 -0.148626185 -0.112104294 > 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/4ihrz1476818011.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/5v3b01476818011.tab") > > try(system("convert tmp/17s6g1476818011.ps tmp/17s6g1476818011.png",intern=TRUE)) character(0) > try(system("convert tmp/253fo1476818011.ps tmp/253fo1476818011.png",intern=TRUE)) character(0) > try(system("convert tmp/3gqbj1476818011.ps tmp/3gqbj1476818011.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.182 0.086 1.283