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(103.75,103.89,104.01,104.28,104.34,104.48,104.56,104.71,104.79,104.87,104.95,105,105.05,105.57,105.98,106.45,107.13,107.87,108.56,109.04,109.98,110.4,110.99,111.23,111.76,112.18,112.88,113.54,114.11,114.8,115.56,116.03,116.98,117.65,118.12,118.6,119.03,119.82,120.76,121.4,122.12,123.08,123.86,124.46,125.14,125.89,126.32,126.93,127.48,128.28,129.11,130.23,131.04,132.2,133.12,134.48,135.74,136.88,138.12,139.99) > 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/1ocjf1476826602.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/2rxoi1476826602.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/3rp8i1476826602.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.94560919 0.89389059 0.84276155 0.79233438 0.74273547 [7] 0.69473620 0.64676493 0.59997918 0.55307096 0.50725175 0.46157307 [13] 0.41594988 0.36950642 0.32342734 0.27690826 0.23122996 0.18666918 [19] 0.14307076 0.10104133 0.06091630 0.02288077 -0.01436803 -0.04931864 [25] -0.08309194 -0.11633041 -0.14905033 -0.18066192 -0.21053212 -0.23766941 [31] -0.26350121 -0.28675120 -0.30817702 -0.32717330 -0.34393704 -0.35861734 [37] -0.37216653 -0.38422049 -0.39509824 -0.40324046 -0.40978551 -0.41261835 [43] -0.41277709 -0.40980667 -0.40373397 -0.39447720 -0.38253313 -0.36868268 [49] -0.35206731 > (mypacf <- c(rpacf$acf)) [1] 0.9456091917 -0.0027040500 -0.0211513348 -0.0208399277 -0.0199622591 [6] -0.0128977600 -0.0272743778 -0.0176532918 -0.0297091023 -0.0196239376 [11] -0.0283462141 -0.0304718243 -0.0396330545 -0.0306515790 -0.0385456259 [16] -0.0286037255 -0.0260319190 -0.0281653641 -0.0226784828 -0.0196773169 [21] -0.0170929753 -0.0293969534 -0.0157405971 -0.0253869311 -0.0321105440 [26] -0.0335283329 -0.0291583009 -0.0233826919 -0.0141352599 -0.0263920975 [31] -0.0154436734 -0.0210651619 -0.0152907177 -0.0157900378 -0.0168736276 [36] -0.0244463934 -0.0218248211 -0.0238472566 -0.0093079930 -0.0181868653 [41] 0.0018553478 -0.0043630741 0.0012692244 0.0041132338 0.0070915768 [46] 0.0061689332 0.0007270741 0.0116783918 > 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/458lk1476826602.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/5k9p51476826602.tab") > > try(system("convert tmp/1ocjf1476826602.ps tmp/1ocjf1476826602.png",intern=TRUE)) character(0) > try(system("convert tmp/2rxoi1476826602.ps tmp/2rxoi1476826602.png",intern=TRUE)) character(0) > try(system("convert tmp/3rp8i1476826602.ps tmp/3rp8i1476826602.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.245 0.088 1.356