R version 3.0.1 (2013-05-16) -- "Good Sport" Copyright (C) 2013 The R Foundation for Statistical Computing 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(58896,57616,56232,53708,79784,78524,58896,45848,47112,47112,48372,51040,54968,53708,45848,47112,83716,91572,70664,58896,61548,62828,69404,75856,77260,64088,65476,48372,96888,111200,78524,68016,74596,82452,94220,108656,108656,99412,95484,71928,111200,129564,113848,96888,99412,108656,121704,137420,126896,120444,120444,99412,129564,149188,133492,116516,121704,142612,151856,164888,154380,137420,133492,102080,122968,145260,120444,106008,120444,134756,142612,163624,153120,126896,129564,104744,125636,144000,122968,108656,121704,137420,134756,166168,160976,140068,141332,113848,130824,157048,137420,125636,145260,157048,147928,189724,179340,155784,149188,119056,136140,151856,132212,132212,154380,166168,159696,205420,193652,171484,162240,129564,141332,162240,146524,142612,160976,176672,159696,200228) > 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/1lg9m1377044133.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/23vkt1377044133.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/39jr61377044133.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.0000000000 -0.0473288860 -0.3437414668 -0.0003157971 -0.1846259509 [6] -0.0246911582 0.2529128253 0.0448761730 -0.2230466774 -0.0069774166 [11] -0.3337613026 -0.0915703525 0.8598024440 0.0102124308 -0.3112943152 [16] -0.0260386613 -0.1488301808 -0.0441785504 0.2437087983 0.0990436440 [21] -0.2108654018 -0.0091539869 -0.2882676519 -0.1126014617 0.7193009709 [26] 0.0395251329 -0.2817679847 -0.0407907653 -0.1213016652 -0.0665567630 [31] 0.2097862663 0.1456430644 -0.1985083788 -0.0151190610 -0.2150595244 [36] -0.1175379010 0.5663455216 0.0731757514 -0.2310124754 -0.0427471530 [41] -0.0845460584 -0.0806250656 0.1699910693 0.1812251720 -0.1921811366 [46] -0.0312074383 -0.1593845606 -0.1188379502 0.4337863011 > (mypacf <- c(rpacf$acf)) [1] -4.732889e-02 -3.467582e-01 -4.401718e-02 -3.503005e-01 -1.086365e-01 [6] 4.205080e-02 1.379598e-02 -1.975904e-01 -3.642627e-02 -5.645501e-01 [11] -4.013107e-01 6.755758e-01 -8.311911e-03 6.705610e-02 -1.443918e-01 [16] -6.019354e-02 6.155638e-02 -5.232016e-02 -2.330567e-02 3.431427e-02 [21] -9.816818e-03 1.362452e-01 2.099170e-02 -4.794604e-02 -8.540951e-02 [26] -7.199508e-02 3.251254e-02 8.255298e-05 -4.259356e-02 -1.003946e-01 [31] -2.784331e-03 -4.232303e-02 -2.702307e-02 6.250072e-02 -2.606996e-02 [36] -1.447754e-01 -6.820157e-03 -4.165260e-03 9.154408e-02 2.237142e-02 [41] -4.088553e-02 8.475133e-03 5.428516e-02 -2.038525e-02 -7.092489e-03 [46] -9.470911e-02 -2.847052e-02 1.064512e-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/4wsbj1377044133.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/5fb9d1377044133.tab") > > try(system("convert tmp/1lg9m1377044133.ps tmp/1lg9m1377044133.png",intern=TRUE)) character(0) > try(system("convert tmp/23vkt1377044133.ps tmp/23vkt1377044133.png",intern=TRUE)) character(0) > try(system("convert tmp/39jr61377044133.ps tmp/39jr61377044133.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.891 0.445 2.316