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 = '0' > par3 = '0' > par2 = '1' > par1 = 'Default' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '1' > par4 <- '0' > 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/156yz1355685742.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/2btju1355685742.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/3ikrd1355685742.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.7295539512 0.3858734356 0.0006332098 -0.4331312202 [6] -0.7285739976 -0.8130022581 -0.7207495659 -0.3886182050 0.0308296890 [11] 0.3663433653 0.6874728929 0.8566254310 0.6651785020 0.3596338374 [16] -0.0121635850 -0.3896130785 -0.6426338217 -0.7384321071 -0.6531041660 [21] -0.3455815703 0.0071443247 > (mypacf <- c(rpacf$acf)) [1] 0.729553951 -0.312934707 -0.333397668 -0.514378090 -0.357729325 [6] -0.267459851 -0.312996785 -0.020073657 -0.008543671 -0.213707561 [11] 0.141314235 0.351783221 -0.172153869 -0.066494413 0.027935970 [16] 0.157987789 0.071028236 0.004340859 0.027254710 0.016092471 [21] -0.095614993 > 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/4a47c1355685742.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/55sas1355685742.tab") > > try(system("convert tmp/156yz1355685742.ps tmp/156yz1355685742.png",intern=TRUE)) character(0) > try(system("convert tmp/2btju1355685742.ps tmp/2btju1355685742.png",intern=TRUE)) character(0) > try(system("convert tmp/3ikrd1355685742.ps tmp/3ikrd1355685742.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.725 0.333 2.042