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(6900,7045,8044,8196,8257,8623,8644,8648,8961,8961,9116,9313,9360,9429,9485,9580,9606,9679,9726,9898,10028,10082,10091,10228,10337,10372,10425,10573,10680,10685,10771,10783,10849,10865,10954,10962,11026,11080,11210,11222,11236,11329,11334,11394,11648,11677,11816,11839,11874,11911,11918,12164,12177,12347,12624,12627,12782,12794,13142,13149,13240,13270,13445,13579,13601,13878,13957,14360,14687,14771,14779,14825,15119,16244,18983,19940,20067,20993,21545,21709,22165,22205,23533,23882,59646) > 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/1qwzx1413720714.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/2wzrf1413720714.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/3yvsv1413720714.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.490780667 0.460170742 0.420791466 0.397640607 [6] 0.369089537 0.344327559 0.314810156 0.281906904 0.259092809 [11] 0.226722721 0.178405519 0.155345487 0.144038110 0.135945752 [16] 0.127989261 0.118849127 0.106927788 0.094875543 0.087154733 [21] 0.077491042 0.071043421 0.063120853 0.054810256 0.048373792 [26] 0.041117708 0.034815775 0.024729262 0.019234326 0.012095786 [31] 0.006653610 -0.001861659 -0.008744826 -0.013563436 -0.021022799 [36] -0.025312799 -0.030093542 -0.034999487 -0.039806649 -0.045801947 [41] -0.050482102 -0.057607854 -0.062004388 -0.065891210 -0.070797844 [46] -0.074417586 -0.078144424 -0.083123282 -0.087149575 > (mypacf <- c(rpacf$acf)) [1] 0.4907806670 0.2888883666 0.1701848056 0.1218757106 0.0781233737 [6] 0.0526752202 0.0261802929 0.0024964019 0.0025549612 -0.0149729216 [11] -0.0504121937 -0.0302485253 -0.0032490463 0.0124459603 0.0185244845 [16] 0.0172495048 0.0100819148 0.0032018213 0.0033783237 -0.0010350990 [21] -0.0006023314 -0.0054017667 -0.0092364256 -0.0072928344 -0.0067210952 [26] -0.0044655967 -0.0091244745 -0.0053771165 -0.0067405667 -0.0056044846 [31] -0.0100839530 -0.0101154077 -0.0072860001 -0.0107145589 -0.0080121763 [36] -0.0074624260 -0.0078726019 -0.0085184440 -0.0110520613 -0.0105646831 [41] -0.0142220436 -0.0125749383 -0.0110763198 -0.0121120134 -0.0109736535 [46] -0.0105612530 -0.0124664812 -0.0120956336 > 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/4xyj11413720714.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/503on1413720714.tab") > > try(system("convert tmp/1qwzx1413720714.ps tmp/1qwzx1413720714.png",intern=TRUE)) character(0) > try(system("convert tmp/2wzrf1413720714.ps tmp/2wzrf1413720714.png",intern=TRUE)) character(0) > try(system("convert tmp/3yvsv1413720714.ps tmp/3yvsv1413720714.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.209 0.198 1.414