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(103.4,103.49,103.51,103.27,103.35,103.34,103.07,103.08,103.1,103.13,103.13,103.18,103.2,103.21,103,102.46,102.52,102.55,102.78,102.81,102.81,102.68,102.72,102.73,102.87,102.93,103.2,102.62,102.18,101.19,100.91,100.72,100.86,100.89,100.47,100.45,100.64,100.63,100.66,100.38,99.68,99.71,99.63,99.63,99.71,99.77,99.76,99.79,98.13,98.13,97.87,97.72,97.72,97.6,97.31,97.31,97.44,96.94,96.94,96.94) > 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.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/1fbpy1445694522.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/2tofz1445694522.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/32jvj1445694522.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.057888233 0.042004338 -0.118828585 -0.183321479 [6] -0.090757521 0.083959322 -0.106184796 0.055870846 0.111014554 [11] -0.064931538 -0.023199460 -0.018941731 0.031259355 0.133647206 [16] -0.042283171 -0.166981217 -0.004407557 -0.031210313 0.250051863 [21] 0.079112162 0.108677181 -0.148015231 0.002911805 -0.050425584 [26] 0.024382833 -0.030567240 -0.026959601 -0.014681066 -0.072417068 [31] -0.101834088 -0.058127258 -0.068494601 0.117884884 0.069050981 [36] -0.022311415 -0.012222515 -0.019763128 -0.044914816 -0.045698839 [41] -0.020528807 -0.056148434 0.084111193 -0.014812622 -0.053224525 [46] 0.042934424 -0.045562858 -0.045592824 0.013442965 > (mypacf <- c(rpacf$acf)) [1] 0.057888233 0.038783255 -0.124012411 -0.174392843 -0.065684393 [6] 0.098174886 -0.155041135 0.008431391 0.125497687 -0.090732141 [11] -0.062410557 0.010502856 0.099791267 0.090177545 -0.117963740 [16] -0.139879108 0.067705645 0.007174721 0.232668107 -0.005169339 [21] 0.106801391 -0.155855664 0.033756982 0.116746755 0.039986468 [26] -0.053715785 -0.117528596 -0.018098711 -0.056195094 -0.085894856 [31] -0.026703634 -0.153656292 0.007139193 0.006429430 0.005506367 [36] 0.033642952 -0.023353075 -0.149782184 -0.091882303 -0.025195818 [41] 0.077667067 -0.006007342 -0.060513633 -0.140848186 0.072348826 [46] 0.023873760 -0.057748427 0.011950008 > 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/487xr1445694522.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/573ui1445694522.tab") > > try(system("convert tmp/1fbpy1445694522.ps tmp/1fbpy1445694522.png",intern=TRUE)) character(0) > try(system("convert tmp/2tofz1445694522.ps tmp/2tofz1445694522.png",intern=TRUE)) character(0) > try(system("convert tmp/32jvj1445694522.ps tmp/32jvj1445694522.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.122 0.196 1.332