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(105.28,107,106.29,108.07,105.41,104.4,102.77,102.44,103.43,102.95,103.52,105.2,105.88,104.88,106.59,107.8,106.31,106.53,106.25,105.87,107.83,108.01,107.9,108.55,108.83,109.39,108.65,108.33,109.76,110.07,109.23,108.4,108.9,109.14,109.27,109.38,109.66,109.87,109.98,111.24,110.03,111.43,110.28,109.53,111.97,111.89,112.93,113.11,112.95,114.08,115.27,114.73,114.97,113.78,113.7,113.91,114.22,115.32,113.5,115.35,113.23,113.65,114.82,113.54,113.97,113.79,113.27,114.35,113.68,115.3,113.69,115.31) > 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/16lr31363704848.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/2eqnu1363704848.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/3xd6e1363704848.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.00000000 0.93122100 0.90855998 0.86311439 0.83158659 0.79971393 [7] 0.75564620 0.71105491 0.66321617 0.62384923 0.57732815 0.53097556 [13] 0.50049483 0.44842159 0.39719848 0.35011342 0.31497158 0.28324898 [19] 0.25038178 0.20729642 0.16845144 0.13801496 0.09816535 0.06473060 [25] 0.03804318 0.00950957 -0.02100995 -0.04920797 -0.08984679 -0.10497399 [31] -0.12123605 -0.15592691 -0.18009129 -0.20896757 -0.22967557 -0.25373611 [37] -0.27481093 -0.30406168 -0.32807649 -0.35406050 -0.37340514 -0.38403433 [43] -0.39412449 -0.41336563 -0.43110325 -0.43199819 -0.43278015 -0.42652748 [49] -0.42744820 > (mypacf <- c(rpacf$acf)) [1] 0.931220995 0.311587945 -0.079109375 0.012543922 0.035971288 [6] -0.115946629 -0.094912482 -0.051439669 0.022108635 -0.054847010 [11] -0.060326246 0.122327119 -0.115862481 -0.161515283 0.020617620 [16] 0.110546267 0.016985730 -0.024090388 -0.074338519 -0.021430521 [21] 0.009661129 -0.105551529 -0.010439086 0.072766688 -0.016283983 [26] -0.060406221 0.008326395 -0.141029644 0.068110479 0.080852614 [31] -0.168309999 -0.003656473 -0.006534452 -0.037872374 -0.039158749 [36] -0.033178851 -0.081062709 -0.020618873 -0.074607942 0.095535309 [41] 0.081094867 -0.113660734 -0.086320931 0.025470721 0.121910761 [46] 0.012296214 -0.024682430 -0.043581337 > 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/4xb991363704848.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/578xx1363704848.tab") > > try(system("convert tmp/16lr31363704848.ps tmp/16lr31363704848.png",intern=TRUE)) character(0) > try(system("convert tmp/2eqnu1363704848.ps tmp/2eqnu1363704848.png",intern=TRUE)) character(0) > try(system("convert tmp/3xd6e1363704848.ps tmp/3xd6e1363704848.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.797 0.298 2.089