R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-pc-linux-gnu (32-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.24,103.43,103.43,103.43,103.31,103.31,103.31,103.31,104.06,104.8,105.36,105.38,105.38,105.38,108.37,112.21,112.05,112.05,112.06,112.05,111.36,111.36,111.36,111.36,111.78,111.89,111.89,111.89,112.02,112.02,112.02,112.02,112.02,112.02,112.02,111.28,111.28,111.28,111.28,110.56,110.56,110.56,110.56,110.56,111.37,109.43,109.43,109.57,109.57,109.57,109.57,109.57,109.39,111.68,111.68,111.68,111.93,111.93,111.93,111.93,111.56,111.89,111.89,111.89,110.82,110.82,110.82,110.82,110.98,110.98,111.78,111.78) > 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/fisher/rcomp/tmp/18q7e1358279164.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/fisher/rcomp/tmp/21sjb1358279164.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/fisher/rcomp/tmp/3tsew1358279164.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.932182622 0.850876143 0.772352365 0.693135399 [6] 0.609775638 0.524860111 0.434058240 0.339528369 0.256308912 [11] 0.175752217 0.097862034 0.027498438 -0.043713114 -0.116745648 [16] -0.158512484 -0.162965526 -0.167713007 -0.175191725 -0.179775953 [21] -0.181745410 -0.185872005 -0.185351031 -0.184479278 -0.183694984 [26] -0.173452751 -0.159350759 -0.145065169 -0.135726895 -0.122633389 [31] -0.116892325 -0.102373133 -0.077083230 -0.052927909 -0.029074585 [36] -0.005615136 0.011751126 0.031054718 0.051697999 0.059357290 [41] 0.048746929 0.038626742 0.026982834 0.014092575 -0.000861306 [46] -0.010242918 -0.040328987 -0.071445603 -0.102617255 > (mypacf <- c(rpacf$acf)) [1] 0.9321826220 -0.1380411351 -0.0126841134 -0.0547886503 -0.0769755258 [6] -0.0585348821 -0.1020165451 -0.0852481582 0.0219774025 -0.0625816769 [11] -0.0419813448 -0.0122347044 -0.0885769075 -0.0837353850 0.1662465491 [16] 0.1945632033 -0.0660983336 -0.0500512667 -0.0247829370 -0.0277835976 [21] -0.0813033008 -0.0333206363 -0.0186778760 -0.0006295115 0.0429454092 [26] 0.0166007480 -0.0078049004 -0.0958011194 0.0322897634 0.0278125406 [31] 0.1146315334 0.0424382508 -0.0195308578 0.0160227139 -0.0205563831 [36] -0.0801364904 0.0271105971 0.0013568515 -0.0730806189 -0.0865365152 [41] 0.0288497451 -0.0442496576 -0.0359962480 -0.0248406368 0.0883420300 [46] -0.1115791266 0.0057564191 -0.0311329050 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/4o76j1358279164.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/fisher/rcomp/tmp/5d6z61358279164.tab") > > try(system("convert tmp/18q7e1358279164.ps tmp/18q7e1358279164.png",intern=TRUE)) character(0) > try(system("convert tmp/21sjb1358279164.ps tmp/21sjb1358279164.png",intern=TRUE)) character(0) > try(system("convert tmp/3tsew1358279164.ps tmp/3tsew1358279164.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.925 0.596 2.507