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(0.69867,0.68968,0.69233,0.68293,0.68399,0.66895,0.68756,0.68527,0.6776,0.68137,0.67933,0.67922,0.68598,0.68297,0.68935,0.69463,0.6833,0.68666,0.68782,0.67669,0.67511,0.67254,0.67397,0.67286,0.66341,0.668,0.68021,0.67934,0.68136,0.67562,0.6744,0.67766,0.68887,0.69614,0.70896,0.72064,0.74725,0.75094,0.77494,0.79487,0.79209,0.79152,0.79308,0.79279,0.79924,0.78668,0.83063,0.90448,0.91819,0.88691,0.91966,0.89756,0.88445,0.8567,0.86092,0.86265,0.89135,0.91557,0.89892,0.89972,0.88305,0.87604,0.9016,0.87456,0.85714,0.82771,0.83566,0.82363,0.83987,0.87638,0.8551,0.84813,0.84712,0.84635,0.86653,0.88291,0.87788,0.88745,0.88476,0.87668,0.87172,0.87036,0.8574,0.84405,0.8321,0.83696,0.83448,0.82188,0.80371,0.80579,0.78827,0.78884,0.79821,0.80665,0.80389,0.81237,0.83271,0.8625,0.85996,0.85076,0.84914,0.85191,0.86192,0.85904,0.84171,0.8472,0.8378,0.83639,0.82674,0.8251,0.8317,0.8252,0.81535,0.80409,0.7931,0.7973,0.79113,0.78861,0.79054,0.7883) > 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/1b6n61425578083.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/2gh1n1425578083.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/30wj31425578083.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.976274892 0.945692115 0.915678881 0.883477401 [6] 0.852077358 0.820247707 0.791065986 0.762020801 0.730404186 [11] 0.696844787 0.660505741 0.623195930 0.580356953 0.540526657 [16] 0.504100081 0.470204022 0.436922753 0.411016882 0.384876883 [21] 0.356437347 0.327967842 0.295655614 0.259344370 0.221913611 [26] 0.182585914 0.144420225 0.110866077 0.076387031 0.040590498 [31] 0.003804806 -0.035773167 -0.072567740 -0.104212427 -0.134258627 [36] -0.161264801 -0.187762328 -0.210963800 -0.230747074 -0.245903918 [41] -0.258903989 -0.271445403 -0.286527595 -0.299180637 -0.308960049 [46] -0.314968651 -0.320549588 -0.321351427 -0.312067156 > (mypacf <- c(rpacf$acf)) [1] 0.976274892 -0.158263397 0.017816562 -0.070285939 0.015988128 [6] -0.036653980 0.049151970 -0.035571316 -0.064598624 -0.053551938 [11] -0.069183476 -0.026707362 -0.141810308 0.080334015 0.007996361 [16] 0.034360676 -0.043037988 0.157887600 -0.096018629 -0.027939152 [21] -0.017499864 -0.093563362 -0.100659937 -0.035979872 -0.061464167 [26] -0.045938439 0.067393299 -0.108013296 -0.025031683 -0.103492268 [31] -0.030833827 0.050815588 0.102616468 -0.021932903 0.071205041 [36] -0.082346023 0.027970946 0.024963273 0.044237992 -0.009828284 [41] -0.007579278 -0.122307364 0.036318045 0.035304762 0.013142670 [46] -0.017783614 0.092883159 0.178081295 > 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/44ua31425578083.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/5dqgl1425578083.tab") > > try(system("convert tmp/1b6n61425578083.ps tmp/1b6n61425578083.png",intern=TRUE)) character(0) > try(system("convert tmp/2gh1n1425578083.ps tmp/2gh1n1425578083.png",intern=TRUE)) character(0) > try(system("convert tmp/30wj31425578083.ps tmp/30wj31425578083.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.139 0.259 1.406