R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(6848,5772,5251,11232,5908,6812,9962,6155,5673,7985,5780,11999,6973,5817,5844,11178,5533,6870,9521,5363,6031,9245,5621,11802,8364,6286,5071,10773,5821,7794,10636,6405,5811,8981,6228,11950,7523,6067,4825,12162,6989,8012,10893,6647,5938,9005,6262,12022,7683,6004,4724,10343,6604,7241,9331,6418,7094,10340,6814,12003,7481,5452,6380,11425,5905,8536,10785,6672,7293,9809,5658,12364,8078,5269,7787,11729,6236,8576,11216,6814,6019,9351,5464,12518) > 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/1krjp1352718449.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/266n11352718449.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/3gxwz1352718449.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.35213178 -0.17736832 0.16630341 -0.07223406 -0.14743513 [7] 0.41339628 -0.17938934 0.01807270 0.12631700 -0.17232806 -0.30942540 [13] 0.80228875 -0.32751537 -0.14025001 0.13220986 -0.08136440 -0.09758764 [19] 0.35628358 -0.16320854 0.03465044 0.05575505 -0.16264535 -0.25365180 [25] 0.64241468 -0.28642283 -0.09384280 0.10549457 -0.07883716 -0.07171989 [31] 0.25259951 -0.15833187 0.05180038 0.03613710 -0.13521613 -0.19195747 [37] 0.53734374 -0.23634676 -0.09085660 0.08720220 -0.10379608 -0.04815386 [43] 0.21138223 -0.14404770 0.06675805 0.03427609 -0.11247251 -0.15209843 [49] 0.38484976 > (mypacf <- c(rpacf$acf)) [1] -0.352131779 -0.344022837 -0.050214011 -0.095498555 -0.218842079 [6] 0.308510881 0.081836702 0.234055421 0.230855536 0.026048366 [11] -0.465104439 0.602139537 0.013858719 -0.008197389 -0.217029436 [16] 0.010446570 0.082954962 -0.010700907 0.163070027 -0.030331336 [21] -0.029969618 -0.105037111 -0.013591392 -0.074691459 -0.121296517 [26] -0.046186182 -0.029474220 0.077569231 0.061755548 -0.046416947 [31] -0.044877623 -0.036832764 0.105870418 0.002817964 0.002431530 [36] 0.030582843 0.066568670 -0.008756761 0.016271921 -0.088556489 [41] -0.073061415 0.002672620 0.011840530 0.013812828 -0.021174004 [46] 0.072608272 0.054903142 -0.141012153 > 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/41o3n1352718449.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/5u1qb1352718449.tab") > > try(system("convert tmp/1krjp1352718449.ps tmp/1krjp1352718449.png",intern=TRUE)) character(0) > try(system("convert tmp/266n11352718449.ps tmp/266n11352718449.png",intern=TRUE)) character(0) > try(system("convert tmp/3gxwz1352718449.ps tmp/3gxwz1352718449.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.099 0.369 2.442