R version 3.2.2 (2015-08-14) -- "Fire Safety" 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(104.93,105.68,106.93,107.29,107.25,106.74,106.44,106.6,107.26,107.35,107.22,106.99,106.87,107.68,108.9,109.48,109.57,109.03,109.58,109.76,110.15,110.2,109.86,109.58,109.52,110.35,111.61,112.06,111.9,111.36,112.09,112.24,112.7,113.36,112.9,112.74,112.7,113.66,114.87,114.97,115,114.57,115.54,115.39,115.46,115.13,114.56,114.62,114.37,114.86,115.82,116.35,115.95,115.64,116.58,116.5,116.48,116.34,115.65,115.42) > 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.291 () > #Author: root > #To cite this work: Wessa P., (2012), (Partial) Autocorrelation Function (v1.0.11) 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) > 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/1r86b1445589657.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/2e5121445589657.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/3zqf71445589657.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.94665434 0.89058624 0.84448369 0.80801033 0.77359833 [7] 0.72665023 0.67449993 0.61672333 0.56813425 0.53005767 0.49642950 [13] 0.45564892 0.39464877 0.33562120 0.28640915 0.24644595 0.20740678 [19] 0.15436288 0.10538778 0.05352361 0.01096445 -0.02467381 -0.05761645 [25] -0.09505607 -0.14588219 -0.19277153 -0.22758421 -0.25085596 -0.27425193 [31] -0.30727800 -0.33288626 -0.36033576 -0.37988581 -0.38676424 -0.39221036 [37] -0.39951850 -0.41448176 -0.42327497 -0.42111771 -0.41645095 -0.41137493 [43] -0.41234175 -0.40228252 -0.39516552 -0.38299802 -0.36801531 -0.35233651 [49] -0.33378328 > (mypacf <- c(rpacf$acf)) [1] 9.466543e-01 -5.361993e-02 6.721741e-02 6.302436e-02 3.168142e-03 [6] -1.270629e-01 -6.129756e-02 -1.004507e-01 3.285106e-02 4.793593e-02 [11] 2.986357e-02 -6.397298e-02 -1.912420e-01 -3.013322e-02 1.427460e-03 [16] 9.304249e-03 -1.342244e-02 -1.138741e-01 3.699375e-02 -8.338211e-02 [21] 6.744709e-04 -1.699645e-02 5.530722e-03 -4.525102e-02 -1.125603e-01 [26] -4.249122e-02 1.520577e-02 2.654498e-02 -1.270490e-02 -5.884844e-02 [31] 4.792103e-02 -7.826756e-02 -1.720244e-02 5.338358e-02 1.499847e-05 [36] -9.293845e-03 -2.922305e-02 -9.831141e-03 1.927682e-02 -5.480735e-02 [41] 1.041896e-02 -2.132123e-02 8.843683e-02 -6.603069e-02 -1.560403e-03 [46] -2.944049e-02 1.271733e-02 1.855559e-02 > 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/4nru31445589657.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/5gyuc1445589657.tab") > > try(system("convert tmp/1r86b1445589657.ps tmp/1r86b1445589657.png",intern=TRUE)) character(0) > try(system("convert tmp/2e5121445589657.ps tmp/2e5121445589657.png",intern=TRUE)) character(0) > try(system("convert tmp/3zqf71445589657.ps tmp/3zqf71445589657.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.179 0.246 1.423