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.13,100.46,101.83,100.82,100.99,99.11,98.99,99.8,100.3,101.56,98.83,101.29,98.24,98.37,99.68,97.8,98.34,98.06,97.19,99.44,99.04,100.81,98.49,101.03,98.59,101.07,99.28,101.65,100.59,101.84,100.27,100.04,97.78,97.59,97.68,100.56,98.9,100.08,101.7,100.9,100.67,100.51,100.01,99.8,97.7,98.14,101.77,99.82,100.03,101.83,98.25,99.88,98.96,98.37,97.52,99.59,97.99,100.68,100.39,99.31,96.93,102.06,97.9,102.29,100.55,100.77,100.68,100.75,100.21,99.85,100.59,101.45) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/1gkva1457596451.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/2x8nw1457596451.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/386st1457596451.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.629145959 0.338370021 -0.194324714 0.083270565 [6] -0.244904052 0.268340227 -0.242030391 0.182887957 -0.106060877 [11] 0.144110699 -0.186311571 0.267511614 -0.271589361 0.096253178 [16] -0.027813355 -0.011300788 -0.011288528 0.073299210 -0.037356067 [21] 0.062043325 -0.026416073 0.002516689 -0.053998623 0.065945385 [26] -0.172866600 0.212617058 -0.122206547 0.149724695 -0.127416403 [31] 0.118019845 -0.231592730 0.209353447 -0.190548718 0.131494343 [36] -0.092317295 0.134864258 -0.150601804 0.256570075 -0.241085218 [41] 0.171562721 -0.156228439 0.115913901 -0.135868659 0.135210083 [46] -0.052809303 -0.032226127 0.076876966 -0.030546234 > (mypacf <- c(rpacf$acf)) [1] -0.629145959 -0.095095930 -0.035117720 -0.055174560 -0.371479277 [6] -0.087700919 -0.091294757 -0.087387247 -0.112920553 0.024801251 [11] -0.093969710 0.105000085 -0.011861429 -0.210617859 -0.069102974 [16] -0.064078231 -0.043421021 -0.119504440 -0.029013992 0.052451418 [21] 0.028367524 -0.019649079 -0.051957616 0.030632580 -0.167505995 [26] 0.049072194 0.026587615 0.148217358 -0.002029840 0.009996406 [31] -0.175430204 -0.039618579 0.001432208 -0.081471029 -0.103400895 [36] -0.053759140 -0.001912984 0.073244803 -0.018418169 -0.021371542 [41] 0.011688368 0.073641739 0.048049326 -0.041766356 0.099435806 [46] -0.081769560 -0.033697167 -0.007117888 > 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/4s4pl1457596451.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/5t5st1457596451.tab") > > try(system("convert tmp/1gkva1457596451.ps tmp/1gkva1457596451.png",intern=TRUE)) character(0) > try(system("convert tmp/2x8nw1457596451.ps tmp/2x8nw1457596451.png",intern=TRUE)) character(0) > try(system("convert tmp/386st1457596451.ps tmp/386st1457596451.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.169 0.165 1.343