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(8.41,8.39,8.43,8.44,8.49,8.47,8.53,8.52,8.51,8.53,8.54,8.53,8.47,8.63,8.67,8.73,8.57,8.55,8.63,8.65,8.44,8.62,8.37,8.59,8.84,8.72,8.8,8.69,8.68,8.57,8.85,8.85,8.85,8.93,8.75,8.78,8.77,9.03,9.01,9.07,8.99,9.02,8.99,8.98,8.94,8.94,8.75,8.86,8.87,8.84,8.84,9.91,10.18,10.34,10.36,10.26,10.16,10.31,10.46,10.54,10.47,10.48,10.46,11.3,11.58,11.69,11.63,11.51,11.37,11.42,11.7,11.75) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/1zktf1353772397.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/2awa71353772397.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/3xadh1353772397.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.0000000000 0.0948055126 0.0157410119 -0.1764749369 -0.1196260884 [6] -0.1124803841 0.1532974995 0.0937254707 -0.1163430211 -0.0751212095 [11] -0.0215438759 0.0399822898 0.3723944761 0.0843529677 0.0758471275 [16] -0.0725876718 -0.0617934515 -0.1814338097 0.0126335524 0.0334602793 [21] -0.0084453606 0.0768131062 -0.0116972810 -0.0703312391 -0.0147541830 [26] -0.0646910424 0.0378651551 0.0937363035 0.1106313724 -0.1478053771 [31] 0.0141475352 -0.1249086433 -0.0544465595 0.1271005056 0.0026237909 [36] -0.0811096841 -0.0902000586 -0.0207725118 -0.0046387454 0.0493296683 [41] 0.0988001400 -0.0864968208 -0.0081771568 -0.1094915044 -0.0398027162 [46] 0.0029255357 -0.0001427277 -0.0501906539 -0.0310805077 > (mypacf <- c(rpacf$acf)) [1] 0.094805513 0.006814173 -0.180231352 -0.089781171 -0.091706277 [6] 0.151228214 0.041802563 -0.192927509 -0.030937219 0.044760682 [11] 0.050734964 0.350982569 -0.050274807 0.093391081 0.080463989 [16] -0.008560862 -0.091673461 -0.067797402 -0.007912643 0.035913321 [21] 0.070151424 -0.051671239 -0.087663025 -0.105787330 -0.133705455 [26] -0.017524761 0.076399293 0.086826713 -0.059229124 0.090346243 [31] -0.084748788 -0.063884768 0.085902129 -0.129801662 -0.019720641 [36] 0.029797002 0.050117168 0.075388949 -0.129164641 -0.058228650 [41] -0.018420938 -0.061459291 -0.012141075 -0.011507926 -0.008417272 [46] 0.025669379 -0.053949613 -0.046473498 > 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/4eorb1353772397.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/5ikul1353772397.tab") > > try(system("convert tmp/1zktf1353772397.ps tmp/1zktf1353772397.png",intern=TRUE)) character(0) > try(system("convert tmp/2awa71353772397.ps tmp/2awa71353772397.png",intern=TRUE)) character(0) > try(system("convert tmp/3xadh1353772397.ps tmp/3xadh1353772397.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.774 0.275 2.047