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(1.894,1.757,3.582,5.321,5.561,5.907,4.944,4.966,3.258,1.964,1.743,1.262,2.086,1.793,3.548,5.672,6.084,4.914,4.990,5.139,3.218,2.179,2.238,1.442,2.205,2.025,3.531,4.977,7.998,4.880,5.231,5.202,3.303,2.683,2.202,1.376,2.422,1.997,3.163,5.964,5.657,6.415,6.208,4.500,2.939,2.702,2.090,1.504,2.549,1.931,3.013,6.204,5.788,5.611,5.594,4.647,3.490,2.487,1.992,1.507,2.306,2.002,3.075,5.331,5.589,5.813,4.876,4.665,3.601,2.192,2.111,1.580,2.288,1.993,3.228,5.000,5.480,5.770,4.962,4.685,3.607,2.222,2.467,1.594,2.228,1.910,3.157,4.809,6.249,4.607,4.975,4.784,3.028,2.461,2.218,1.351,2.070,1.887,3.024,4.596,6.398,4.459,5.382,4.359,2.687,2.249,2.154,1.169,2.429,1.762,2.846,5.627,5.749,4.502,5.720,4.403,2.867,2.635,2.059,1.511,2.359,1.741,2.917,6.249,5.760,6.250,5.134,4.831,3.695,2.462,2.146,1.579) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '1' > par4 = '1' > par3 = '0' > par2 = '1' > par1 = 'Default' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '1' > par4 <- '1' > par3 <- '0' > par2 <- '1' > par1 <- 'Default' > #'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/1qxlw1355686540.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/2pvt21355686540.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/3zw3k1355686540.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.14581607 0.10079387 0.12368505 -0.25071744 -0.39878135 [7] -0.33608762 -0.46624922 -0.17850798 0.11141980 0.01228118 0.29443293 [13] 0.69120763 0.22263587 0.15050925 0.03367347 -0.21788749 -0.29841039 [19] -0.36105886 -0.41148511 -0.10650715 0.03391709 > (mypacf <- c(rpacf$acf)) [1] 0.14581607 0.08125931 0.10113710 -0.29911041 -0.38907363 -0.30302712 [7] -0.44704188 -0.25545174 -0.01841951 -0.25999084 -0.24761656 0.37400394 [13] 0.17512717 -0.00654178 -0.20400962 -0.07449648 0.04037019 0.02049699 [19] 0.03904299 0.06605441 -0.03848482 > 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/40y001355686540.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/5bv131355686540.tab") > > try(system("convert tmp/1qxlw1355686540.ps tmp/1qxlw1355686540.png",intern=TRUE)) character(0) > try(system("convert tmp/2pvt21355686540.ps tmp/2pvt21355686540.png",intern=TRUE)) character(0) > try(system("convert tmp/3zw3k1355686540.ps tmp/3zw3k1355686540.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.628 0.279 1.889