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(1.5,1.439,1.49,1.502,1.531,1.611,1.644,1.559,1.553,1.494,1.298,1.215,1.179,1.267,1.282,1.304,1.32,1.413,1.38,1.426,1.394,1.354,1.415,1.406,1.44,1.449,1.489,1.53,1.548,1.518,1.507,1.499,1.487,1.487,1.491,1.56,1.587,1.584,1.647,1.666,1.699,1.671,1.622,1.669,1.663,1.624,1.621,1.607,1.671,1.699,1.751,1.821,1.77,1.734,1.703,1.752,1.823,1.827,1.773,1.75,1.733,1.765,1.791,1.773,1.712,1.735,1.729,1.769,1.776,1.709,1.678,1.691) > 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/1t4591413750381.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/2awh01413750381.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/3eotw1413750381.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.95036223 0.87820331 0.80512187 0.73616518 0.68378414 [7] 0.64403938 0.61662792 0.60531927 0.59412667 0.57766888 0.54877580 [13] 0.49381585 0.43168581 0.36558156 0.30407424 0.25471311 0.21480938 [19] 0.18232251 0.15034315 0.11769713 0.08050919 0.03816452 -0.01173464 [25] -0.06385717 -0.11338397 -0.15369165 -0.18399973 -0.21213069 -0.22670753 [31] -0.23636416 -0.24792132 -0.26451361 -0.28583120 -0.30944059 -0.33534004 [37] -0.36591901 -0.39132233 -0.40951485 -0.42285427 -0.42616428 -0.42019280 [43] -0.40552802 -0.39451651 -0.39173055 -0.38975891 -0.38332350 -0.37287121 [49] -0.35449179 > (mypacf <- c(rpacf$acf)) [1] 9.503622e-01 -2.580790e-01 4.244146e-03 -3.059092e-03 1.247246e-01 [6] 3.232345e-02 7.222336e-02 1.200570e-01 -4.763410e-02 -2.679441e-02 [11] -9.786980e-02 -2.142989e-01 4.436746e-03 -7.979102e-02 9.684872e-03 [16] -5.746363e-03 -1.613819e-02 -3.459369e-02 -1.014648e-01 -1.336704e-03 [21] -6.703671e-02 -1.457597e-02 -4.878078e-02 -3.600009e-02 -7.325813e-03 [26] 2.108342e-03 9.829836e-05 -8.411905e-02 1.211680e-01 -1.000659e-02 [31] -2.901405e-02 -3.285658e-02 -1.430715e-02 -5.220257e-04 -6.916098e-02 [36] -7.146682e-02 -3.671936e-03 -2.663328e-02 -2.110797e-02 -1.628148e-02 [41] 6.576902e-02 5.244384e-02 -7.783896e-02 -4.624431e-02 3.599322e-02 [46] 8.655970e-02 1.804884e-02 6.688419e-02 > 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/46xqx1413750381.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/5vhtj1413750381.tab") > > try(system("convert tmp/1t4591413750381.ps tmp/1t4591413750381.png",intern=TRUE)) character(0) > try(system("convert tmp/2awh01413750381.ps tmp/2awh01413750381.png",intern=TRUE)) character(0) > try(system("convert tmp/3eotw1413750381.ps tmp/3eotw1413750381.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.188 0.212 1.404