R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 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(82303,79596,74472,73562,66618,69029,89899,93774,90305,83799,80320,82497,84420,84646,84186,83269,77793,81145,101691,107357,104253,95963,91432,94324,93855,92183,87600,83641,78195,79604,100846,105293,102518,93132,87479,85476,85460,82868,79941,76909,72613,72496,93244,99126,96748,89318,84724,83111,87497,86961,82319,79196,76898,77971,97335,106855,105401,99108,93456,92506,94602,93027,89722,87391,83030,83390,104501,110393,111017,103434,97817,96893) > 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/16o7v1413467428.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/203up1413467428.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/3bhth1413467428.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.339731791 -0.262272552 -0.440188117 -0.290286506 [6] 0.037779549 0.215708015 0.074727466 -0.206089129 -0.374470977 [11] -0.245423178 0.262422301 0.805358085 0.309106490 -0.207734697 [16] -0.382485284 -0.261188211 0.019289150 0.168861816 0.064042719 [21] -0.167208231 -0.313072191 -0.205617810 0.175069382 0.645568600 [26] 0.279294935 -0.150971611 -0.299591483 -0.214237853 -0.008692544 [31] 0.122427491 0.064156886 -0.109146525 -0.215273254 -0.149137890 [36] 0.110932457 0.478468045 0.231204902 -0.105368353 -0.220936897 [41] -0.168874781 -0.010727903 0.098347507 0.069396672 -0.071864034 [46] -0.137092962 -0.108554893 0.057734145 0.306357639 > (mypacf <- c(rpacf$acf)) [1] 0.33973179 -0.42697015 -0.23224363 -0.18133930 -0.01050112 -0.03281500 [7] -0.16140805 -0.26555558 -0.37604756 -0.41484095 -0.08211711 0.57345207 [13] -0.27019486 0.10398370 0.09025933 0.11039361 -0.02636811 -0.05027984 [19] -0.02045241 -0.08371001 -0.04290775 -0.05597098 -0.22129316 -0.03268784 [25] -0.14347790 -0.07872867 -0.06578440 -0.07047516 -0.13613768 -0.07355187 [31] -0.02938964 -0.03495788 0.03774834 0.02058731 0.01248452 -0.06815726 [37] 0.03751023 -0.04930200 -0.05448449 -0.08497386 -0.02007619 -0.04946197 [43] -0.01585203 -0.07361828 0.04850033 -0.04021744 0.04568956 -0.16817912 > 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/4x4r61413467428.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/5ed451413467428.tab") > > try(system("convert tmp/16o7v1413467428.ps tmp/16o7v1413467428.png",intern=TRUE)) character(0) > try(system("convert tmp/203up1413467428.ps tmp/203up1413467428.png",intern=TRUE)) character(0) > try(system("convert tmp/3bhth1413467428.ps tmp/3bhth1413467428.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.179 0.186 1.380