R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(95870,95523,95208,94541,101097,100781,95870,92581,92928,92928,93244,93910,93559,96190,97172,96190,99799,97488,92261,90964,90964,91599,89004,90964,89319,90964,93559,94541,96852,95870,89981,87670,86692,87670,86057,86692,84728,88021,89635,89981,96190,96190,88021,86057,86057,87039,82764,80799,78524,79186,82133,79821,86057,87039,80799,78524,77221,78524,74910,73613,68390,69688,70004,70355,76559,75893,68390,65097,63799,65444,59208,54964,47115,47777,47777,47115,52684,53004,46448,45151,42524,46133,39577,35653,28146,29764,27800,28462,33373,34355,31093,30742,30742,35017,27484,22573,14058,20929,19946,20293,28146,27164,23555,25204,25204,31093,24222,20293,14058,22258,21595,21911,28782,28146,25835,26186,27800,31409,25835,21275) > 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/1lftg1344776991.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/2blo11344776991.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/36e9i1344776991.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.97755783 0.95635629 0.93892625 0.92222184 0.90223905 [7] 0.88172667 0.86473680 0.84965403 0.83175535 0.81611035 0.80182494 [13] 0.78238254 0.75241037 0.72263198 0.69637423 0.66955666 0.64049784 [19] 0.61027107 0.58433379 0.56048067 0.53434091 0.51013734 0.48886582 [25] 0.46251190 0.42952611 0.39771733 0.36905831 0.33964630 0.30798905 [31] 0.27475736 0.24579321 0.21890556 0.19199500 0.16634737 0.14436682 [37] 0.12054230 0.09194283 0.06391024 0.03890988 0.01320700 -0.01533187 [43] -0.04593270 -0.07021457 -0.09214140 -0.11484369 -0.13594915 -0.15320058 [49] -0.17051573 > (mypacf <- c(rpacf$acf)) [1] 0.977557831 0.016605851 0.074922387 0.012155380 -0.074826093 [6] -0.023515889 0.057612734 0.034289869 -0.054417349 0.049408118 [11] 0.009421869 -0.126688741 -0.246924672 -0.050051110 0.016769347 [16] -0.017790712 -0.020275576 -0.058049562 0.026760455 0.020562523 [21] -0.041023584 0.015408200 0.048923506 -0.078666551 -0.116580194 [26] -0.017615867 -0.001902874 -0.018084635 -0.015035024 -0.074601033 [31] -0.004410207 0.011733929 0.009037106 -0.013162622 0.056995361 [36] 0.006238025 -0.076344514 -0.030971965 -0.002748736 -0.020643411 [41] -0.024778751 -0.071780947 0.036626318 0.011982060 -0.014054890 [46] -0.015049087 0.032006651 0.018682167 > 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/4xkm91344776991.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/5o8do1344776991.tab") > > try(system("convert tmp/1lftg1344776991.ps tmp/1lftg1344776991.png",intern=TRUE)) character(0) > try(system("convert tmp/2blo11344776991.ps tmp/2blo11344776991.png",intern=TRUE)) character(0) > try(system("convert tmp/36e9i1344776991.ps tmp/36e9i1344776991.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.220 0.256 1.469