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(6.11,6.13,6.15,6.15,6.16,6.18,6.21,6.22,6.23,6.26,6.28,6.28,6.29,6.32,6.36,6.37,6.38,6.38,6.4,6.41,6.42,6.43,6.44,6.47,6.47,6.48,6.51,6.54,6.56,6.57,6.6,6.62,6.65,6.71,6.76,6.78,6.8,6.83,6.86,6.86,6.87,6.88,6.9,6.92,6.93,6.94,6.96,6.98,6.99,7.01,7.06,7.07,7.08,7.08,7.1,7.11,7.22,7.24,7.25,7.26,7.27,7.3,7.32,7.34,7.35,7.36,7.39,7.41,7.43,7.46,7.47,7.5) > 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/1xutq1353082085.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/2ojzn1353082085.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/3nklx1353082085.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.081090052 -0.099141522 -0.148134649 0.038007776 [6] 0.065339356 0.075804023 0.032510218 -0.092807616 -0.098516701 [11] -0.021970703 -0.147519591 -0.026765336 0.055248930 -0.065293796 [16] -0.086945580 -0.045057622 -0.049842493 -0.011574375 0.065664784 [21] 0.033307516 -0.020922826 0.060629334 0.191626964 0.143095945 [26] -0.069945241 -0.081122595 -0.070195821 0.061263917 0.061485208 [31] -0.064525787 -0.086177571 -0.097123871 0.066452318 -0.032910494 [36] -0.027683042 0.076204299 -0.006060547 0.025815088 -0.133236573 [41] -0.012944426 0.020086477 0.096401421 0.074749638 -0.028926176 [46] -0.089086894 -0.023708486 0.020258954 0.015474083 > (mypacf <- c(rpacf$acf)) [1] 0.0810900523 -0.1064168730 -0.1329808555 0.0524644131 0.0323321475 [6] 0.0584858722 0.0450802799 -0.0794490890 -0.0686970600 -0.0227196656 [11] -0.2009897907 -0.0293480716 0.0387054835 -0.1163364483 -0.0399681145 [16] -0.0182832560 -0.0923331696 -0.0169065955 0.0287964345 -0.0259386713 [21] 0.0039992572 0.0630529975 0.1666773330 0.1528841495 -0.0893457594 [26] -0.0612362660 -0.0717153039 -0.0295346899 -0.0194090953 -0.0876835185 [31] -0.0332152360 -0.0525525178 0.0989064723 -0.0157134322 0.0026266564 [36] 0.1069916267 -0.0036424622 0.0901326861 -0.1138616121 -0.0052480490 [41] -0.0199526320 -0.0009594825 0.0112469001 -0.0195449704 -0.0952696762 [46] -0.0845759365 -0.0283420714 -0.0542324065 > 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/4s98y1353082085.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/5k4x51353082085.tab") > > try(system("convert tmp/1xutq1353082085.ps tmp/1xutq1353082085.png",intern=TRUE)) character(0) > try(system("convert tmp/2ojzn1353082085.ps tmp/2ojzn1353082085.png",intern=TRUE)) character(0) > try(system("convert tmp/3nklx1353082085.ps tmp/3nklx1353082085.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.142 0.341 2.462