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(84728,84412,84092,83430,89981,89635,84728,81466,81781,81781,82133,82764,83746,83746,83115,81466,89981,91279,89319,84728,86692,83746,85075,85710,86372,84728,85075,82764,89981,92261,90301,86692,90617,86372,90301,89981,90964,87355,91279,90964,96852,95523,90301,87670,91279,86372,89981,90617,91946,89004,90617,91599,95208,92261,88337,84092,88021,77221,82448,85390,88337,84092,84092,84092,86372,83115,78839,75261,77857,67724,73933,77541,78204,74595,74910,73933,77221,74910,70355,67062,72630,60537,68390,71968,71968,67724,63799,63484,67062,63799,57595,53319,57911,47115,56928,62150,63799,60191,55631,58893,60191,59208,49391,44835,48093,38280,48413,52022,54964,50057,45466,48093,49391,46795,36982,32706,36631,25835,37613,44835) > 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/1u2f81375799372.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/2zmlt1375799372.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/3orks1375799372.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.94790238 0.90526697 0.85572849 0.82620581 0.78567941 [7] 0.75796603 0.73618798 0.72365371 0.70318187 0.69210223 0.68757000 [13] 0.70013200 0.64795920 0.60883566 0.56351062 0.53636243 0.49797173 [19] 0.47383387 0.45269020 0.44000973 0.41829299 0.40339590 0.39332619 [25] 0.39690037 0.34807568 0.31176424 0.26871632 0.24336092 0.20637827 [31] 0.18441905 0.16033717 0.14528006 0.11903081 0.10228122 0.08819115 [37] 0.08556652 0.04215424 0.01252790 -0.02312078 -0.04234591 -0.07005467 [43] -0.08184491 -0.09661709 -0.10509802 -0.12495884 -0.13603215 -0.14763229 [49] -0.15225551 > (mypacf <- c(rpacf$acf)) [1] 0.947902382 0.066495621 -0.082620819 0.161769416 -0.095014670 [6] 0.075222997 0.103374747 0.049081778 -0.040350607 0.088274217 [11] 0.102395605 0.170866954 -0.617557544 0.140106752 0.079121083 [16] -0.101808100 0.062886467 0.038425175 -0.041022358 0.026522332 [21] -0.026510687 0.084745928 -0.085818557 -0.059760502 -0.132117620 [26] 0.009574504 0.006387182 -0.014106124 -0.004645646 0.005709566 [31] -0.091581278 0.033600279 -0.043553700 0.058511260 -0.071716936 [36] -0.075133877 0.014539862 0.007294533 -0.021743977 0.017285747 [41] 0.014243626 0.003859414 -0.029038517 -0.021886810 0.016662740 [46] -0.028074010 -0.067426230 -0.046564615 > 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/48ck91375799372.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/5jclj1375799372.tab") > > try(system("convert tmp/1u2f81375799372.ps tmp/1u2f81375799372.png",intern=TRUE)) character(0) > try(system("convert tmp/2zmlt1375799372.ps tmp/2zmlt1375799372.png",intern=TRUE)) character(0) > try(system("convert tmp/3orks1375799372.ps tmp/3orks1375799372.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.897 0.448 2.342