R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(161949,161634,161287,160652,167176,166856,161949,158687,159007,159007,159323,159990,159990,157043,155745,157043,161634,160967,154763,149510,148527,146563,147892,149510,148874,147545,144950,147545,149856,149190,141656,138394,135132,132505,132190,134150,131523,130541,129559,135132,135768,132505,123670,119745,113541,110910,112208,114172,114172,112559,112208,117465,121710,119745,113190,109932,103061,98817,102079,105341,105341,101097,100781,106319,109932,108630,102079,97835,88652,85075,86372,91946,92261,84092,87039,94226,97488,95523,86692,80484,73297,67724,70004,74910,73613,66426,68706,75893,79821,77541,68706,64782,58893,52684,53666,58573,59208,53319,54302,62502,64462,61173,49075,42871,34671,26502,29129,32706,32075,25835,29444,38280,42204,40244,32391,26186,19631,12093,13427,15707) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/1142z1344777792.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/2b8oz1344777792.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/3fs9u1344777792.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.426069612 -0.195505576 -0.330459375 -0.149182646 [6] -0.102223237 -0.166221195 -0.071815091 -0.121605326 -0.345616202 [11] -0.207871953 0.393569767 0.840826820 0.370611699 -0.169605807 [16] -0.265161168 -0.134742179 -0.091707701 -0.146357924 -0.050403771 [21] -0.114017525 -0.307542445 -0.172873293 0.363248956 0.697053159 [26] 0.316962615 -0.148583379 -0.231373886 -0.137049385 -0.089291006 [31] -0.106972777 -0.035681465 -0.116830460 -0.293047959 -0.144943313 [36] 0.319126960 0.579852351 0.280787561 -0.101997033 -0.184733189 [41] -0.132137846 -0.094651776 -0.072658440 0.000521881 -0.097941261 [46] -0.256522837 -0.117861011 0.268066734 0.452274390 > (mypacf <- c(rpacf$acf)) [1] 4.260696e-01 -4.606685e-01 -1.940266e-02 -4.020247e-02 -2.282467e-01 [6] -1.486966e-01 9.662662e-03 -4.042320e-01 -5.112479e-01 -1.372555e-01 [11] 2.669644e-01 5.362759e-01 -2.063852e-01 4.245070e-02 6.455928e-02 [16] -1.504686e-02 1.042307e-01 -6.343313e-02 -2.336974e-02 -1.752604e-03 [21] 1.623703e-01 1.203559e-02 8.789305e-05 -1.807502e-02 5.396653e-02 [26] 1.697392e-03 -3.853107e-02 -5.061752e-02 2.798540e-05 6.407003e-02 [31] -3.599429e-02 -5.101919e-02 -8.070980e-02 3.695915e-03 -4.895081e-02 [36] -4.833032e-02 -1.338948e-02 8.794838e-03 3.924955e-02 -3.205419e-02 [41] -4.164298e-02 -3.120762e-03 1.212962e-01 1.286058e-02 4.218634e-02 [46] 7.862173e-03 2.237588e-02 -3.158062e-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/4vbtr1344777792.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/510xl1344777792.tab") > > try(system("convert tmp/1142z1344777792.ps tmp/1142z1344777792.png",intern=TRUE)) character(0) > try(system("convert tmp/2b8oz1344777792.ps tmp/2b8oz1344777792.png",intern=TRUE)) character(0) > try(system("convert tmp/3fs9u1344777792.ps tmp/3fs9u1344777792.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.274 0.246 1.514