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(3.65,3.66,3.69,3.7,3.7,3.71,3.71,3.71,3.72,3.72,3.73,3.74,3.78,3.78,3.79,3.79,3.8,3.81,3.83,3.84,3.88,3.91,3.96,3.96,3.97,3.98,3.99,3.99,4,4,4.02,4.02,4.02,4.03,4.03,4.03,4.04,4.04,4.05,4.05,4.05,4.05,4.06,4.06,4.06,4.06,4.07,4.07,4.08,4.08,4.08,4.09,4.09,4.09,4.09,4.1,4.1,4.11,4.11,4.12,4.12,4.12,4.12,4.12,4.15,4.15,4.15,4.15,4.16,4.16,4.16,4.2) > 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/1z0211353682698.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/2wjpq1353682698.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/3qxir1353682698.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.106948328 0.236645175 0.028386273 0.152006461 [6] -0.056252441 0.058798099 0.018971730 0.190426134 0.095286584 [11] 0.241032045 -0.088915857 0.016162729 -0.070407173 -0.024225440 [16] -0.143983251 0.068138027 -0.076238045 0.100202336 -0.052743385 [21] 0.096585747 -0.063838939 -0.027629159 -0.089580800 -0.045892055 [26] -0.055023503 0.032915787 -0.106474309 -0.027104666 -0.055868398 [31] -0.069985823 -0.054499010 -0.160701197 -0.070268918 -0.013024548 [36] -0.030725644 -0.064475353 -0.071113813 -0.058119988 -0.067251436 [41] -0.118140441 -0.080528356 -0.039332599 0.020404760 -0.044039870 [46] -0.072803603 -0.006989585 -0.038246306 -0.116246560 > (mypacf <- c(rpacf$acf)) [1] 0.1069483275 0.2278129420 -0.0165601043 0.1036197769 -0.0868633607 [6] 0.0179840124 0.0452627608 0.1679404960 0.0778356538 0.1582865723 [11] -0.1837208348 -0.0950550895 -0.0212453894 -0.0361245371 -0.0702543698 [16] 0.0787745588 -0.0876972037 0.0338712100 -0.0194548453 0.0575649223 [21] 0.0386756635 -0.0553740872 -0.0341240759 -0.0395853696 0.0219783767 [26] 0.0106591540 -0.0793714476 -0.0936969797 -0.0111878277 -0.0910259325 [31] 0.0684121797 -0.1260275603 -0.0051668801 0.0492195365 0.0157522980 [36] -0.0565131004 -0.0007104906 -0.0571471881 -0.0331003590 -0.0396835678 [41] -0.0524505768 0.0496569262 0.0323851735 -0.0831647583 -0.0889714520 [46] 0.0566499189 -0.0356627057 -0.0380121603 > 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/4hnky1353682698.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/5yofq1353682698.tab") > > try(system("convert tmp/1z0211353682698.ps tmp/1z0211353682698.png",intern=TRUE)) character(0) > try(system("convert tmp/2wjpq1353682698.ps tmp/2wjpq1353682698.png",intern=TRUE)) character(0) > try(system("convert tmp/3qxir1353682698.ps tmp/3qxir1353682698.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.776 0.443 2.209