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(103.77,103.82,103.86,103.9,103.63,103.65,103.7,103.77,103.94,104.03,104.03,104.29,104.35,104.67,104.73,104.86,104.05,104.15,104.27,104.33,104.41,104.4,104.41,104.6,104.61,104.65,104.55,104.51,104.74,104.89,104.91,104.93,104.95,104.97,105.16,105.29,105.35,105.36,105.45,105.3,105.73,105.86,105.85,105.95,105.97,106.15,105.37,105.39,105.39,105.38,105.23,105.34,104.98,105.16,105.27,105.27,105.33,105.33,105.46,105.54,105.59,105.57,105.62,105.57,105.33,105.34,105.5,105.47,105.59,105.65,105.8,105.87) > 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/1puip1413916832.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/2fknd1413916832.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/3n8nf1413916832.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.92810092 0.86753597 0.80920458 0.76036889 0.70060619 [7] 0.64296692 0.58627521 0.53882308 0.49643620 0.45763714 0.41769372 [13] 0.38243374 0.35014957 0.33116628 0.32109294 0.31021670 0.27170984 [19] 0.23112113 0.20045075 0.17980490 0.14967846 0.11879751 0.08228184 [25] 0.04939209 0.03418883 0.01703398 -0.03070938 -0.07643483 -0.11596982 [31] -0.14327759 -0.19402267 -0.23963379 -0.27542146 -0.31026173 -0.34112832 [37] -0.36032324 -0.38329022 -0.39601476 -0.39748053 -0.39959293 -0.38660992 [43] -0.36548044 -0.35050382 -0.32735345 -0.29322134 -0.25596624 -0.25112719 [49] -0.24726150 > (mypacf <- c(rpacf$acf)) [1] 0.9281009155 0.0444688337 -0.0102876092 0.0392302284 -0.0964248007 [6] -0.0275788182 -0.0250748299 0.0241666497 0.0212115252 0.0055723630 [11] -0.0236597558 0.0028376243 -0.0024322305 0.0733893929 0.0707562770 [16] -0.0001179954 -0.2012326056 -0.0805876878 0.0269315984 0.0506666460 [21] -0.0363942317 -0.0144886243 -0.0713214872 -0.0461060446 0.1053779528 [26] -0.0020605502 -0.2314388422 -0.0612851168 -0.0218651003 0.0142225789 [31] -0.2077206421 -0.0344102762 0.1005043725 -0.0472387858 -0.0478672403 [36] 0.0207732419 -0.0541505908 0.0464007163 0.1093529689 -0.0699808150 [41] -0.0079170484 0.0670108569 0.0879290897 0.0990639499 0.0286160868 [46] 0.0219688742 -0.1559606973 -0.0289138468 > 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/4w9yo1413916832.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/5fh421413916832.tab") > > try(system("convert tmp/1puip1413916832.ps tmp/1puip1413916832.png",intern=TRUE)) character(0) > try(system("convert tmp/2fknd1413916832.ps tmp/2fknd1413916832.png",intern=TRUE)) character(0) > try(system("convert tmp/3n8nf1413916832.ps tmp/3n8nf1413916832.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.189 0.235 1.427