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(31.1,31.8,32.5,34.4,35.5,35.5,36.6,37.1,37.9,38.1,39,41.5,41.8,41.9,44.6,46.1,46.4,47.2,47.7,49.2,49.3,49.3,49.5,50.1,51.9,52.6,53.2,53.5,53.7,53.7,53.9,54.1,54.8,55.4,55.9,56.8,58.4,59.3,60.3,60.5,60.8,61,61.1,61.3,61.4,61.5,63.9,63.9,64,64.1,64.5,64.5,65.9,66.8,68.7,69.2,69.6,70.2,70.6,70.7,70.7,71,72.1,73.7,77.4,79.7,91.6,93.6,94.3,97.3,101.7,103,103.1,104.6,107.2,107.7,108.3,108.8,113.1,113.8,113.8,116.5,116.9,117.6) > 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/10iqd1337512437.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/2h2f01337512437.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/3r6qx1337512437.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.956907941 0.912363217 0.866409603 0.822007400 [6] 0.775512731 0.727848526 0.684284046 0.639912094 0.594471333 [11] 0.548127850 0.503719617 0.461099394 0.416189436 0.371230072 [16] 0.331464168 0.294480024 0.257238782 0.221535375 0.197941059 [21] 0.177128382 0.159104854 0.141997192 0.125494152 0.109075819 [26] 0.093110733 0.077138515 0.061343426 0.045628393 0.029500561 [31] 0.012987685 -0.002301493 -0.017320772 -0.031326766 -0.045647914 [36] -0.059895484 -0.074198389 -0.087767053 -0.101221760 -0.112068168 [41] -0.123291868 -0.134996655 -0.147051636 -0.159941377 -0.173302041 [46] -0.186861954 -0.200809461 -0.212661833 -0.224416062 > (mypacf <- c(rpacf$acf)) [1] 0.956907941 -0.039247014 -0.039748749 -0.005650412 -0.049590868 [6] -0.039944117 0.022910796 -0.037604143 -0.041063431 -0.035945255 [11] -0.008557520 -0.009919619 -0.055239455 -0.031446888 0.029629426 [16] -0.001901134 -0.032542474 -0.007749395 0.110828835 0.001915883 [21] 0.011747607 -0.003258610 -0.022621767 -0.025359358 -0.002530641 [26] -0.019757285 -0.023632246 -0.025059713 -0.019648978 -0.020115448 [31] -0.012446398 -0.019307692 0.004650884 -0.016258647 -0.018824711 [36] -0.014732597 0.006944017 -0.013591379 0.021846539 -0.019695205 [41] -0.026499045 -0.023951422 -0.028838928 -0.029359296 -0.022352846 [46] -0.030325358 0.001433015 -0.022846844 > 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/413541337512437.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/5d34o1337512437.tab") > > try(system("convert tmp/10iqd1337512437.ps tmp/10iqd1337512437.png",intern=TRUE)) character(0) > try(system("convert tmp/2h2f01337512437.ps tmp/2h2f01337512437.png",intern=TRUE)) character(0) > try(system("convert tmp/3r6qx1337512437.ps tmp/3r6qx1337512437.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.969 0.298 1.265