R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing 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(47.43,47.43,47.51,47.96,47.99,48.05,48.05,48.01,48,48.06,48.23,48.4,48.4,48.5,48.41,48.35,48.53,48.52,48.52,48.49,48.45,48.65,48.74,48.74,48.74,48.79,48.82,48.82,49.2,49.3,49.3,49.34,49.47,49.65,49.7,49.75,49.75,49.7,50.09,50.19,50.53,50.55,50.55,50.55,50.58,50.61,50.94,51.01,51.01,51.04,51.15,51.31,51.31,51.34,51.34,51.34,51.47,51.95,51.97,51.92,51.92,51.91,51.97,52.14,52.33,52.4,52.4,52.41,52.71,53.17,53.33,53.32,53.32,53.3,53.31,53.72,53.87,53.91,53.91,53.96,54.02,54.33,54.48,54.54) > 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/1t2yf1384774225.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/2ftpm1384774225.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/35ymw1384774225.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.960767421 0.920033243 0.880817367 0.848720336 [6] 0.816894580 0.784370170 0.748936254 0.711170493 0.673717980 [11] 0.641210084 0.609161175 0.576327587 0.540831495 0.504228392 [16] 0.468115838 0.436237606 0.408756566 0.379512637 0.347578380 [21] 0.314255900 0.282404687 0.254089994 0.226056514 0.196560946 [26] 0.165335233 0.132125181 0.098772086 0.070430564 0.045808589 [31] 0.019875992 -0.007875613 -0.035962469 -0.063285560 -0.087471923 [36] -0.110464163 -0.134853143 -0.160961479 -0.188218798 -0.208652917 [41] -0.228108636 -0.245009405 -0.263225717 -0.282328394 -0.302364661 [46] -0.318935858 -0.334295661 -0.342971947 -0.352973239 -0.363975028 [51] -0.374408526 -0.383400046 -0.389138056 -0.393931263 -0.399071455 [56] -0.405394130 -0.410855045 -0.410918601 -0.406897833 -0.402785127 [61] -0.399339797 > (mypacf <- c(rpacf$acf)) [1] 0.9607674206 -0.0395288292 -0.0010887255 0.0710802002 -0.0172156136 [6] -0.0237554299 -0.0479196754 -0.0493570912 -0.0190633369 0.0358157024 [11] -0.0213090904 -0.0278833324 -0.0438207373 -0.0345185149 -0.0195354440 [16] 0.0224649271 0.0284554062 -0.0423449144 -0.0411364136 -0.0305000761 [21] -0.0106977029 0.0104122427 -0.0290128454 -0.0401896960 -0.0322545314 [26] -0.0450220522 -0.0368432301 0.0255098654 0.0103970972 -0.0405967438 [31] -0.0298917083 -0.0189645040 -0.0233938291 -0.0003516495 -0.0233441646 [36] -0.0457772682 -0.0327127216 -0.0364052355 0.0491863485 -0.0314957108 [41] -0.0027055691 -0.0332027290 -0.0278972764 -0.0269959790 0.0075031995 [46] -0.0313170675 0.0512807702 -0.0298697773 -0.0264798951 0.0027359248 [51] -0.0218074568 0.0032870102 -0.0211927122 -0.0223989279 -0.0207160771 [56] -0.0014556125 0.0382727852 0.0176370123 -0.0218153018 -0.0094007131 > 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/4p9or1384774225.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/5o75p1384774225.tab") > > try(system("convert tmp/1t2yf1384774225.ps tmp/1t2yf1384774225.png",intern=TRUE)) character(0) > try(system("convert tmp/2ftpm1384774225.ps tmp/2ftpm1384774225.png",intern=TRUE)) character(0) > try(system("convert tmp/35ymw1384774225.ps tmp/35ymw1384774225.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.362 0.497 2.837