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(11236,10954,9580,10337,8961,10372,12782,15119,19940,13957,10849,9429,11816,11329,11334,9898,8961,10783,13149,16244,20067,13601,10573,8623,10962,11911,11677,9679,9116,11394,13240,18983,21545,14360,11839,9726,12347,12624,11918,10028,10228,11026,13878,22165,23533,13445,12164,9606,12177,13142,11210,9485,10082,10680,13579,21709,22205,14687,11222,8196,12794,12627,11080,10425,10865,10771,14771,20993,23882,14825,11648,10091) > 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/1byeo1415864478.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/2y5ew1415864478.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/3q2sf1415864478.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.595551087 0.014371999 -0.354448544 -0.353018319 [6] -0.176521069 -0.078848172 -0.155813013 -0.298288371 -0.295932414 [11] 0.012514201 0.515995378 0.814449059 0.472376853 -0.005831684 [16] -0.325980387 -0.324068498 -0.157300716 -0.080414195 -0.135012343 [21] -0.240203610 -0.235089036 0.019186158 0.422516757 0.633974410 [26] 0.353930635 -0.010242281 -0.267980110 -0.254269497 -0.135699191 [31] -0.083909222 -0.115054402 -0.185637234 -0.183012231 0.020820519 [36] 0.316713664 0.435086365 0.226494840 -0.024886734 -0.205726657 [41] -0.193009960 -0.116669061 -0.082668569 -0.089182673 -0.129270091 [46] -0.118581081 0.013718756 0.195955610 0.265426269 > (mypacf <- c(rpacf$acf)) [1] 0.595551087 -0.527350271 -0.114750935 0.048645305 -0.096282867 [6] -0.193880357 -0.248451632 -0.262691682 -0.154204241 0.178404911 [11] 0.442934836 0.421988354 -0.387225656 0.291650927 0.022813198 [16] -0.059113885 0.061767127 -0.064093989 0.064446892 0.015245402 [21] -0.028671660 -0.008642956 -0.093875814 0.015282282 -0.052767982 [26] 0.078853361 -0.010328553 0.018361014 -0.074483463 0.070308306 [31] 0.006640311 -0.020317022 -0.021455488 0.002090582 -0.109648078 [36] -0.129755105 0.064787423 -0.067578911 -0.066817364 -0.055174996 [41] 0.009864663 -0.024828207 -0.033487310 0.037405644 -0.013573559 [46] -0.143184575 -0.012818801 0.048228648 > 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/4qt8s1415864478.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/5yv5q1415864478.tab") > > try(system("convert tmp/1byeo1415864478.ps tmp/1byeo1415864478.png",intern=TRUE)) character(0) > try(system("convert tmp/2y5ew1415864478.ps tmp/2y5ew1415864478.png",intern=TRUE)) character(0) > try(system("convert tmp/3q2sf1415864478.ps tmp/3q2sf1415864478.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.142 0.215 1.366