R version 2.15.3 (2013-03-01) -- "Security Blanket" Copyright (C) 2013 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(79.57,77.45,75.79,74.88,74.5,74.59,74.59,73.57,73.3,73.23,73,72.31,72.31,71.24,70.82,70.66,69.94,69.87,69.87,68.88,68.09,68.38,66.78,67.2,67.2,66.67,65.86,66.05,66.31,66.39,66.39,65.72,65.52,64.93,65.27,65.04,65.02,64.72,64.68,64.41,64.79,64.71,64.71,64.83,64.77,64.19,64.27,64.23,64.23,63.03,62.85,62.15,61.69,62.1,62.1,61.81,61.28,61.05,61.08,60.98,60.98,61.11,60.58,60.37,59.44,59.29,59.29,59.33,59.06,58.75,58.92,58.73) > 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/1qdyx1363609890.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/2jqfd1363609890.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/3v64b1363609890.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.099164439 0.051872829 0.007656570 -0.025609709 [6] -0.028782762 0.276426866 0.024054672 -0.101300853 0.063961451 [11] -0.045423730 0.073386696 0.158701383 0.151426484 -0.056506528 [16] 0.072878395 -0.100410006 0.036570540 0.124170475 0.157238290 [21] 0.006026915 -0.084191107 -0.170219079 0.073050711 0.047157810 [26] 0.041286214 -0.096609094 -0.098499648 -0.159170870 0.064868132 [31] 0.111492213 -0.004515795 0.015153293 -0.091074127 -0.065261452 [36] -0.062100199 0.020320673 -0.066612082 0.028028278 -0.159598631 [41] -0.086458256 -0.131171214 0.043174165 -0.009307762 -0.013717226 [46] -0.081086901 -0.067480229 0.003201058 0.086600601 > (mypacf <- c(rpacf$acf)) [1] 0.099164439 0.042456745 -0.001496562 -0.028732426 -0.024201757 [6] 0.287762371 -0.030911594 -0.144148026 0.095481484 -0.030414801 [11] 0.102974243 0.065373121 0.120218865 -0.030916609 0.026700220 [16] -0.091341452 0.047460322 0.077353158 0.098530276 0.006786583 [21] -0.141633880 -0.142638076 0.159001924 -0.055794310 -0.038675749 [26] -0.160863275 0.003315703 -0.073598468 0.049849644 0.046244441 [31] -0.045092083 -0.002151500 -0.036311392 0.028323598 -0.052680988 [36] -0.075180465 0.005351754 -0.006772276 -0.076371945 0.002451235 [41] -0.070926260 0.015055339 -0.042790795 -0.020559176 0.034782668 [46] 0.031982614 0.038488215 0.063136094 > 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/4cby21363609890.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/5ks2l1363609890.tab") > > try(system("convert tmp/1qdyx1363609890.ps tmp/1qdyx1363609890.png",intern=TRUE)) character(0) > try(system("convert tmp/2jqfd1363609890.ps tmp/2jqfd1363609890.png",intern=TRUE)) character(0) > try(system("convert tmp/3v64b1363609890.ps tmp/3v64b1363609890.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.336 0.346 2.672