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(40927,40856,40778,40635,42103,42032,40927,40194,40265,40265,40336,40486,40856,40414,40856,40486,41661,42181,39973,39381,39894,39823,39381,39453,40336,40194,40336,40336,41298,41440,38790,38790,39823,39310,38427,38790,39674,39232,39161,38206,39602,39894,37023,36952,38427,37615,36218,36810,37465,37615,37173,36290,38128,38128,34893,34673,35556,33939,32314,32835,33939,33055,32464,31210,32906,32977,29743,29664,30256,28418,26430,27235,28339,27164,27093,25910,27826,28197,24585,23780,24293,22305,20246,20909,22156,20688,20909,20026,21864,22084,17668,17375,18180,16050,14134,14797,16414,14504,14355,12880,14504,15017,10451,10451,11113,9347,7359,8392,10230,8242,9055,7950,9717,10308,5592,5229,5963,4196,2800,3384) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '60' > #'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/1kqkp1406624482.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/2hydn1406624482.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/3guqm1406624482.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.970504258 0.941070334 0.919919162 0.897951532 [6] 0.868975281 0.840660270 0.824634979 0.808242215 0.784392232 [11] 0.759197259 0.738479184 0.720988413 0.688780888 0.656217804 [16] 0.632140196 0.607470107 0.576268121 0.545226406 0.526410846 [21] 0.507028112 0.480531816 0.453875784 0.432654016 0.414354023 [26] 0.383047243 0.351635864 0.328220235 0.304648240 0.275148872 [31] 0.246910069 0.230451122 0.213329727 0.189150131 0.164917399 [36] 0.145128619 0.127298467 0.098766691 0.070348327 0.049511698 [41] 0.029273803 0.003793266 -0.019538789 -0.032627574 -0.046780290 [46] -0.067601508 -0.087303069 -0.102399465 -0.116014495 -0.138290544 [51] -0.161145401 -0.177126460 -0.192336420 -0.212531059 -0.231227431 [56] -0.240539755 -0.250492850 -0.265646631 -0.278443244 -0.286413008 [61] -0.293320168 > (mypacf <- c(rpacf$acf)) [1] 0.9705042584 -0.0139050461 0.1273724686 -0.0255188848 -0.1143568922 [6] -0.0072625026 0.1726932510 -0.0110693686 -0.0850679865 -0.0462974798 [11] 0.0059074340 0.0491740849 -0.2131355293 -0.0130802810 0.0472989722 [16] -0.0370363131 -0.0577347124 -0.0029769795 0.0993652199 -0.0276020100 [21] -0.0432250651 -0.0205985497 0.0073980938 0.0224584086 -0.1368978984 [26] -0.0071545810 0.0099714285 -0.0287910165 -0.0349032906 0.0235000650 [31] 0.0611951081 -0.0300908491 -0.0325930781 -0.0239793442 -0.0193149031 [36] -0.0010547518 -0.0786591552 -0.0107013353 -0.0063145672 -0.0164178433 [41] -0.0232492393 0.0368767745 0.0225835301 -0.0334312226 -0.0250302002 [46] -0.0053982891 -0.0129193534 0.0002217489 -0.0428739597 -0.0353567929 [51] -0.0154837305 -0.0133176532 -0.0195111135 0.0140288418 0.0088720308 [56] -0.0266315897 0.0001389443 0.0159799812 -0.0025494081 0.0056437449 > 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/4gjhe1406624482.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/5g3jr1406624482.tab") > > try(system("convert tmp/1kqkp1406624482.ps tmp/1kqkp1406624482.png",intern=TRUE)) character(0) > try(system("convert tmp/2hydn1406624482.ps tmp/2hydn1406624482.png",intern=TRUE)) character(0) > try(system("convert tmp/3guqm1406624482.ps tmp/3guqm1406624482.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.216 0.185 1.413