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(163.93,164.28,164.58,165.97,166.3,166.27,166.27,166.44,166.26,166.64,166.07,166.19,166.19,166.19,166.35,166.52,167.17,167.16,167.16,167.16,167.39,168.46,168.55,168.58,168.58,169.21,169.29,169.24,169.53,169.57,169.57,169.67,170.04,170.39,170.57,170.48,170.48,170.48,170.49,170.72,171.11,171.07,171.07,171.07,171.05,172.28,172.74,172.86,172.86,173.24,173.2,173.38,172.89,172.98,172.98,172.69,172.77,172.65,172.3,172.17,172.17,173.07,173.27,173.05,173.41,173.37,173.37,173.08,173.97,175.23,174.9,174.83) > 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/fisher/rcomp/tmp/15bd91353097407.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/fisher/rcomp/tmp/25b891353097407.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/fisher/rcomp/tmp/3ozn21353097407.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.94239867 0.88385596 0.82527537 0.78929484 0.76079943 [7] 0.72686614 0.69256264 0.65781962 0.62099744 0.58690102 0.54956982 [13] 0.51989246 0.48726366 0.45148930 0.41392309 0.37534565 0.34152538 [19] 0.30338623 0.26196694 0.21850052 0.17118597 0.13453630 0.09640845 [25] 0.05816828 0.01455635 -0.02333197 -0.05714037 -0.08169898 -0.10568776 [31] -0.13308548 -0.16248651 -0.19193156 -0.21494184 -0.23322779 -0.24920110 [37] -0.26617532 -0.28574615 -0.30693080 -0.32659199 -0.34125486 -0.35153428 [43] -0.36258127 -0.37622008 -0.39210201 -0.40846706 -0.41428228 -0.41567085 [49] -0.41310000 > (mypacf <- c(rpacf$acf)) [1] 0.942398673 -0.038068612 -0.031350471 0.170396767 0.043608699 [6] -0.070776581 0.014872788 0.002358066 -0.056291883 0.002797651 [11] -0.042749037 0.035791897 -0.042961721 -0.057975694 -0.020868138 [16] -0.032511789 -0.004949206 -0.070329844 -0.059426801 -0.042509390 [21] -0.078466699 0.038589354 -0.048470932 -0.056307653 -0.063983029 [26] 0.025277092 -0.017840641 0.042332749 -0.011616498 -0.052516309 [31] -0.016778360 -0.029057935 0.029113010 0.002604425 -0.007692077 [36] -0.025885167 -0.026682984 -0.029662297 -0.019964773 0.005549804 [41] -0.007939809 -0.037066734 -0.038190610 -0.033723735 -0.049126984 [46] 0.037364791 0.008072894 -0.006969795 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/40hrz1353097407.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/fisher/rcomp/tmp/534zq1353097407.tab") > > try(system("convert tmp/15bd91353097407.ps tmp/15bd91353097407.png",intern=TRUE)) character(0) > try(system("convert tmp/25b891353097407.ps tmp/25b891353097407.png",intern=TRUE)) character(0) > try(system("convert tmp/3ozn21353097407.ps tmp/3ozn21353097407.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.796 0.438 2.227