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(13396,13637,15467,13722,14727,14961,14026,13895,14474,15759,15995,14119,15342,15796,15435,16195,15572,16223,15921,14143,16290,16579,14314,13318,11938,12574,13298,12124,11757,12803,12800,11293,12992,13426,13174,13648,12801,13183,15703,14859,14350,16444,14207,13329,14795,15248,16081,15670,14805,15779,17945,15280,16773,16362,15774,15505,16397,16060,16748,16137,15523,16267,18066,16105,16883,17034,16452,16234,16658,18133,17488,15853,17198,16719,17635,16726,17503,17074,17054,15451,16374,17242,16684,16489) > 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/1z1v61413739724.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/2nhiy1413739724.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/3se4p1413739724.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.74471007 0.65030430 0.69951761 0.63954363 0.60503789 [7] 0.56724275 0.46327238 0.45981852 0.34727618 0.22287198 0.28730182 [13] 0.32270022 0.16930916 0.09253774 0.09334539 0.09911437 0.09210182 [19] 0.08871114 0.05364408 0.08564219 0.02250887 -0.04206300 0.03579610 [25] 0.08456455 -0.01617317 -0.05690956 -0.07621533 -0.04215433 -0.05508016 [31] -0.09799544 -0.09655196 -0.12268302 -0.18932564 -0.23052171 -0.20369890 [37] -0.16706857 -0.22035271 -0.32113417 -0.29575538 -0.26598828 -0.28318455 [43] -0.25993269 -0.26947496 -0.27144047 -0.30447788 -0.31618653 -0.27096706 [49] -0.20651246 > (mypacf <- c(rpacf$acf)) [1] 0.7447100733 0.2148848637 0.3748910579 0.0287995141 0.1004867892 [6] -0.0480658885 -0.1760781084 0.0428425230 -0.2904505682 -0.1854934685 [11] 0.1803264313 0.2889226341 -0.1362427268 -0.1626888307 0.0082248245 [16] 0.1140628890 0.0468757333 0.1335136907 -0.0844190467 0.0234233666 [21] -0.0808183065 -0.0901930545 -0.0466875873 0.0327772883 -0.0588226159 [26] -0.0470812124 -0.0734991219 0.1200262102 -0.0603805181 -0.0118589027 [31] 0.0144879306 -0.1571334105 0.0089983224 -0.0705354330 -0.0037424516 [36] -0.0223403869 0.0540158703 -0.1615680246 0.0460445526 0.0004568612 [41] 0.0485303031 0.0656922468 -0.0240689668 -0.0349903545 -0.1416660900 [46] 0.0428271279 -0.0780774669 0.0073192780 > 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/4r9541413739724.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/5vrhp1413739724.tab") > > try(system("convert tmp/1z1v61413739724.ps tmp/1z1v61413739724.png",intern=TRUE)) character(0) > try(system("convert tmp/2nhiy1413739724.ps tmp/2nhiy1413739724.png",intern=TRUE)) character(0) > try(system("convert tmp/3se4p1413739724.ps tmp/3se4p1413739724.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.189 0.169 1.372