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(98.68,99.21,99.36,100.72,102.27,102.62,102.97,102.88,102.9,103.01,103.02,103.73,104.18,103.73,103.78,103.61,103.84,103.86,104.14,104.05,104.01,104.49,104.83,104.78,104.95,105.28,105.28,105.91,106.81,106.39,107.02,106.92,107.01,106.79,107.41,107.13,107.54,108.48,108.5,108.27,109.42,110.09,109.98,109.99,109.54,108.85,106.76,107.56,106.24,108.85,111.11,111.85,110.68,106.96,106.74,105.73,105.66,104.01,106.86,108.84,110.66,106.93,103.74,101.64,102.17,101.13,100.64,100.43,99.77,99.79,99.47,99.63) > 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/1tjzk1357845354.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/2e1ry1357845354.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/3bpiv1357845354.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.889647484 0.747803181 0.604357536 0.517447280 [6] 0.462310205 0.429030270 0.411651119 0.397304540 0.352995965 [11] 0.273500957 0.195457701 0.151746950 0.129071304 0.093810112 [16] 0.049997120 0.006269003 -0.033460943 -0.077456491 -0.119256348 [21] -0.140848612 -0.155358295 -0.165692986 -0.197546386 -0.249397841 [26] -0.294357815 -0.330764729 -0.349991782 -0.352821223 -0.344515843 [31] -0.337853259 -0.327715721 -0.322789383 -0.326631583 -0.332700542 [36] -0.328647063 -0.326925756 -0.322986585 -0.309997118 -0.304987700 [41] -0.301596224 -0.285542756 -0.254285701 -0.220484966 -0.178925945 [46] -0.145485063 -0.119993073 -0.120584342 -0.121549789 > (mypacf <- c(rpacf$acf)) [1] 0.889647484 -0.209418402 -0.069902234 0.194451612 0.026429806 [6] 0.021966785 0.084845964 0.016293821 -0.140906445 -0.126764282 [11] 0.038608661 0.085747467 -0.046423976 -0.139129033 -0.021707484 [16] -0.008432651 -0.045401590 -0.042992782 -0.003315943 0.021301856 [21] -0.089218045 -0.004264700 -0.060069668 -0.124801648 -0.013880141 [26] -0.039134910 -0.005005811 0.003161324 -0.031857997 -0.046933794 [31] 0.050396014 0.002738148 -0.070916852 -0.030259106 0.012416034 [36] -0.080461865 -0.034785921 0.050366138 -0.094475256 -0.072359167 [41] 0.079975057 0.044631298 -0.053922174 0.045164058 -0.008625211 [46] -0.021533106 -0.116864552 0.024898341 > 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/45nin1357845354.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/52m5f1357845354.tab") > > try(system("convert tmp/1tjzk1357845354.ps tmp/1tjzk1357845354.png",intern=TRUE)) character(0) > try(system("convert tmp/2e1ry1357845354.ps tmp/2e1ry1357845354.png",intern=TRUE)) character(0) > try(system("convert tmp/3bpiv1357845354.ps tmp/3bpiv1357845354.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.893 0.557 2.444