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(1.26,1.26,1.28,1.34,1.39,1.47,1.57,1.63,1.72,1.43,1.35,1.41,1.44,1.43,1.43,1.42,1.45,1.51,1.48,1.48,1.45,1.38,1.46,1.45,1.41,1.45,1.47,1.47,1.53,1.56,1.66,1.79,1.78,1.46,1.41,1.43,1.43,1.45,1.35,1.35,1.29,1.29,1.26,1.3,1.3,1.16,1.24,1.15,1.21,1.22,1.17,1.13,1.15,1.2,1.23,1.25,1.38,1.28,1.26,1.25,1.26,1.28,1.31,1.22,1.23,1.36,1.54,1.58,1.44,1.29,1.28,1.23,1.2,1.22,1.19,1.17,1.22,1.29,1.39,1.53,1.82,1.77,1.63,1.57) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '60' > #'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/155so1388412504.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/22jvy1388412504.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/39gs61388412504.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.841597538 0.616456536 0.418558236 0.271257866 [6] 0.187602635 0.121761811 0.071981471 0.050266639 0.079261914 [11] 0.102967241 0.131553599 0.176268962 0.172209391 0.142410163 [16] 0.060779624 -0.025392103 -0.066850986 -0.083302947 -0.104431481 [21] -0.114039059 -0.104730366 -0.074545917 -0.006445486 0.051948698 [26] -0.006343743 -0.085206358 -0.158755264 -0.224427549 -0.245426776 [31] -0.256754015 -0.268564771 -0.283302045 -0.269172554 -0.227904249 [36] -0.187564296 -0.161318158 -0.181592387 -0.210079765 -0.236415357 [41] -0.252020750 -0.250693672 -0.240987114 -0.228866842 -0.204980817 [46] -0.172079835 -0.131666939 -0.051305081 0.075982192 0.151384552 [51] 0.167216020 0.137140498 0.078812138 0.037059830 0.013041249 [56] -0.019034650 -0.043747284 -0.024568224 0.019969205 0.054968926 [61] 0.068438071 > (mypacf <- c(rpacf$acf)) [1] 0.841597538 -0.314794666 0.005183526 0.002508012 0.065603525 [6] -0.080467354 0.011994404 0.047731243 0.141420393 -0.080145014 [11] 0.095668179 0.101272466 -0.135003692 -0.007560726 -0.163543219 [16] 0.029727600 0.050738851 -0.046731456 -0.080464071 0.068739472 [21] -0.023120792 0.053780427 0.079475911 -0.023287187 -0.356170363 [26] 0.073406527 -0.021593596 -0.064949998 0.019051722 -0.047597809 [31] -0.045780400 -0.112713922 0.056371532 0.085273295 -0.144053970 [36] -0.144818083 -0.027854825 -0.014468466 0.078325995 -0.059554251 [41] -0.074225548 0.006106236 -0.048335693 0.026778656 0.045906077 [46] -0.007065707 0.036497007 0.208486623 0.010778222 -0.046050334 [51] -0.040183976 -0.035907334 -0.070762252 0.019843822 -0.024316754 [56] 0.073320353 0.007308801 -0.060153126 -0.007962196 -0.096247197 > 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/4ptfs1388412504.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/5xm3j1388412504.tab") > > try(system("convert tmp/155so1388412504.ps tmp/155so1388412504.png",intern=TRUE)) character(0) > try(system("convert tmp/22jvy1388412504.ps tmp/22jvy1388412504.png",intern=TRUE)) character(0) > try(system("convert tmp/39gs61388412504.ps tmp/39gs61388412504.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.962 1.029 4.948