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(65,65.3,62.9,63.5,62.1,59.3,61.6,61.5,60.1,59.5,62.7,65.5,63.8,63.8,62.7,62.3,62.4,64.8,66.4,65.1,67.4,68.8,68.6,71.5,75,84.3,84,79.1,78.8,82.7,85.3,84.5,80.8,70.1,68.2,68.1,72.3,73.1,71.5,74.1,80.3,80.6,81.4,87.4,89.3,93.2,92.8,96.8,100.3,95.6,89,87.4,86.7,92.8,98.6,100.8,105.5,107.8,113.7,120.3,126.5,134.8,134.5,133.1,128.8,127.1,129.1,128.4,126.5,117.1,114.2,109.1) > 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/1qgz31363625320.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/2mu5o1363625320.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/3kwsa1363625320.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.442701848 0.117461035 -0.044028447 0.003036451 [6] 0.142336540 0.044031524 -0.036314577 -0.221532016 -0.341133259 [11] -0.366844119 -0.160015849 -0.110342915 -0.023397577 0.090537266 [16] 0.010453687 -0.016294229 0.096548275 0.221978663 0.243572332 [21] 0.014786684 -0.125530028 -0.027992146 -0.028728177 -0.111315526 [26] -0.131444104 -0.236486471 -0.213522617 -0.132897716 -0.004027473 [31] 0.098640976 0.099895415 0.021075466 0.005439266 0.015943705 [36] 0.071585327 0.270302053 0.200869738 0.081582004 -0.107398538 [41] -0.105520377 -0.014914337 0.026925470 0.008655886 -0.070142724 [46] -0.065736588 -0.109838459 -0.025677744 -0.002572532 > (mypacf <- c(rpacf$acf)) [1] 0.442701848 -0.097664700 -0.072670551 0.080306842 0.147187064 [6] -0.121929267 -0.028746165 -0.200024349 -0.217746306 -0.212202446 [11] 0.084241890 -0.139691879 0.100017170 0.218326986 -0.047140348 [16] -0.078250592 0.194683596 -0.008440940 -0.090741884 -0.216375316 [21] -0.107285472 0.029717717 -0.040289319 -0.149682498 0.041007831 [26] -0.097117020 0.009847879 0.010132127 0.103893977 0.019456933 [31] 0.084376829 -0.155251408 -0.141061249 -0.094337006 -0.017778369 [36] 0.025026637 0.015812245 0.130154125 0.017771849 0.092502723 [41] -0.001307489 -0.020927623 -0.039444455 -0.120271148 -0.020129822 [46] -0.033953645 -0.038179341 -0.033730929 > 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/49kxj1363625320.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/522aq1363625320.tab") > > try(system("convert tmp/1qgz31363625320.ps tmp/1qgz31363625320.png",intern=TRUE)) character(0) > try(system("convert tmp/2mu5o1363625320.ps tmp/2mu5o1363625320.png",intern=TRUE)) character(0) > try(system("convert tmp/3kwsa1363625320.ps tmp/3kwsa1363625320.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.840 0.301 2.121