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(46.56,46.72,47.01,47.26,47.49,47.51,47.52,47.66,47.71,47.87,48,48,48.05,48.25,48.72,48.94,49.16,49.18,49.25,49.34,49.49,49.57,49.63,49.67,49.7,49.8,50.09,50.49,50.73,51.12,51.15,51.41,51.61,52.06,52.17,52.18,52.19,52.74,53.05,53.38,53.78,53.82,53.88,53.96,54.14,54.2,54.35,54.36,54.39,54.77,54.91,55.06,55.38,55.41,55.47,55.58,55.67,55.97,56.03,56.06,56.08,56.43,56.65,56.96,57.37,57.51,57.61,57.7,57.91,58.12,58.18,58.16) > 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/1b0kh1356537318.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/2yd431356537318.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/3j2uf1356537318.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.96085141 0.92017580 0.87967629 0.84036692 0.80207411 [7] 0.76252981 0.72156277 0.68052318 0.64088515 0.60271973 0.56518635 [13] 0.52781213 0.48850416 0.44862413 0.41062444 0.37443945 0.33898897 [19] 0.30272766 0.26566745 0.22778388 0.19153151 0.15559628 0.11963484 [25] 0.08458719 0.04782671 0.01000293 -0.02653323 -0.06132506 -0.09468407 [31] -0.12633389 -0.15894657 -0.19094797 -0.22015583 -0.24529380 -0.26874071 [37] -0.28997860 -0.31247906 -0.33255896 -0.35085106 -0.36481230 -0.37552764 [43] -0.38499156 -0.39462321 -0.40188206 -0.40687100 -0.40936640 -0.40948369 [49] -0.40957519 > (mypacf <- c(rpacf$acf)) [1] 0.960851411 -0.039857445 -0.018513046 -0.006106121 -0.008677641 [6] -0.038036196 -0.040134124 -0.023737398 -0.006409831 -0.006489571 [11] -0.016441295 -0.021141135 -0.048619946 -0.032822105 -0.003478799 [16] -0.005509681 -0.018489249 -0.035923509 -0.035289849 -0.039143252 [21] -0.011084323 -0.029650577 -0.032061897 -0.018096799 -0.052616515 [26] -0.047843768 -0.021577995 -0.017365067 -0.020404371 -0.013182046 [31] -0.047104975 -0.028827710 -0.005170373 0.010784114 -0.016746040 [36] -0.005566869 -0.048237952 -0.001393880 -0.015449441 0.016951406 [41] 0.007768478 -0.011582707 -0.027028667 0.006239771 -0.002202011 [46] -0.001042899 0.004619984 -0.020414898 > 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/4fvr11356537318.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/5osy81356537318.tab") > > try(system("convert tmp/1b0kh1356537318.ps tmp/1b0kh1356537318.png",intern=TRUE)) character(0) > try(system("convert tmp/2yd431356537318.ps tmp/2yd431356537318.png",intern=TRUE)) character(0) > try(system("convert tmp/3j2uf1356537318.ps tmp/3j2uf1356537318.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.943 0.550 2.484