R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing 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(9.27,9.30,9.35,9.33,9.37,9.42,9.45,9.38,9.40,9.43,9.45,9.49,9.47,9.48,9.52,9.53,9.53,9.54,9.57,9.61,9.61,9.63,9.64,9.60,9.64,9.66,9.67,9.70,9.72,9.73,9.77,9.72,9.68,9.62,9.79,9.77,9.79,9.77,9.78,9.81,9.74,9.70,9.78,9.85,9.83,9.90,9.93,9.85,9.95,9.97,10.02,9.97,9.95,9.95,9.98,10.00,10.04,10.05,10.06,10.09,10.14,10.13,10.12,10.10,10.12,10.06,10.21,10.18,10.26,10.39,10.41,10.46) > 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/fisher/rcomp/tmp/1o1v01385056447.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/2iwds1385056447.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/3rbky1385056447.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.217021467 -0.030970379 -0.024103099 -0.019383695 [6] -0.030664144 -0.034954897 -0.054726737 0.009177567 0.074356035 [11] 0.024513934 0.006562327 0.051936652 -0.139401317 0.112332904 [16] -0.028830323 0.111323571 -0.205810750 0.077377110 -0.143685276 [21] 0.092067293 0.113496443 -0.179064723 0.052810749 0.152746579 [26] 0.011319418 0.068115709 -0.125770587 -0.024196546 -0.065165008 [31] 0.087530297 -0.177982197 0.195998921 -0.108248146 0.085193091 [36] -0.001727171 -0.118754099 -0.006650006 -0.086544166 0.003380379 [41] 0.042638718 -0.003817748 0.016410048 -0.075606868 0.089293103 [46] -0.003142467 -0.052320183 -0.010877563 -0.003345897 > (mypacf <- c(rpacf$acf)) [1] -0.217021467 -0.081927336 -0.051933104 -0.041666548 -0.051641407 [6] -0.062648850 -0.090864667 -0.039146095 0.054196189 0.046237875 [11] 0.024836465 0.066144327 -0.117148624 0.070406150 0.014396525 [16] 0.143819093 -0.155035888 0.013523243 -0.174946583 0.028688920 [21] 0.132398878 -0.128738914 -0.012976883 0.127220708 0.076632135 [26] 0.119569018 -0.044894988 -0.039789585 -0.064643151 0.017726547 [31] -0.110256410 0.116950430 -0.047303407 0.027995974 -0.048452478 [36] -0.198316289 -0.023561142 -0.094248175 -0.073145599 0.007777422 [41] -0.042718880 -0.003283501 0.040348142 -0.035434642 0.073577323 [46] -0.114103920 0.039412709 -0.092528938 > 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/4h8wt1385056447.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/5xsrd1385056447.tab") > > try(system("convert tmp/1o1v01385056447.ps tmp/1o1v01385056447.png",intern=TRUE)) character(0) > try(system("convert tmp/2iwds1385056447.ps tmp/2iwds1385056447.png",intern=TRUE)) character(0) > try(system("convert tmp/3rbky1385056447.ps tmp/3rbky1385056447.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.731 0.412 2.125