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(1.55,1.56,1.56,1.57,1.57,1.58,1.58,1.58,1.58,1.59,1.59,1.60,1.60,1.61,1.62,1.62,1.63,1.63,1.63,1.63,1.63,1.63,1.64,1.64,1.64,1.65,1.65,1.66,1.67,1.67,1.68,1.68,1.69,1.70,1.71,1.72,1.72,1.73,1.73,1.73,1.73,1.74,1.75,1.75,1.75,1.76,1.76,1.76,1.77,1.78,1.78,1.79,1.79,1.79,1.79,1.79,1.83,1.83,1.83,1.83,1.84,1.84,1.84,1.85,1.85,1.85,1.86,1.86,1.86,1.87,1.87,1.88) > 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/120nn1352920892.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/2i71l1352920892.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/3k2bw1352920892.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.257045597 -0.062049409 -0.004280192 -0.045276407 [6] -0.003176705 -0.095929805 0.099066383 0.058070168 -0.120153017 [11] -0.060009630 0.049516472 -0.110663029 -0.034850126 0.040962776 [16] 0.168532563 -0.097534877 -0.071104691 -0.044674505 0.082895282 [21] -0.126666934 0.151425170 -0.008754330 0.067058572 0.075445073 [26] -0.152160828 0.076548560 -0.101674625 0.041564678 0.101708064 [31] -0.110228321 0.033010981 0.007684282 -0.085068817 0.091883686 [36] -0.052626299 0.007517087 -0.069566497 0.006246405 -0.052793494 [41] 0.056732608 -0.036020491 0.055461926 0.014465712 0.022852213 [46] 0.013195030 -0.027801185 0.115438118 -0.078454583 > (mypacf <- c(rpacf$acf)) [1] -0.2570455974 -0.1371860667 -0.0629462348 -0.0793217477 -0.0479873934 [6] -0.1362370513 0.0249292767 0.0722142580 -0.0872363561 -0.1286456064 [11] -0.0235983924 -0.1477074385 -0.1330624694 -0.0615506073 0.1169778529 [16] -0.0483710529 -0.0912747488 -0.1561470302 -0.0028058397 -0.1507513331 [21] 0.0670695300 -0.0775907446 0.0433050053 0.1387430944 -0.0551615188 [26] -0.0160956620 -0.0691783064 -0.0072663369 0.0618592241 -0.1241578076 [31] -0.0064318044 0.0373100274 -0.0171389547 0.0561724208 0.0068984770 [36] -0.0554808867 -0.1150924219 -0.0842704737 -0.1612498813 0.0170224577 [41] 0.0004381982 0.0133755188 -0.0420493672 0.0362355406 -0.0216315840 [46] -0.0132941706 0.0434594840 -0.0402699267 > 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/415wm1352920892.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/5twu41352920892.tab") > > try(system("convert tmp/120nn1352920892.ps tmp/120nn1352920892.png",intern=TRUE)) character(0) > try(system("convert tmp/2i71l1352920892.ps tmp/2i71l1352920892.png",intern=TRUE)) character(0) > try(system("convert tmp/3k2bw1352920892.ps tmp/3k2bw1352920892.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.93 0.44 2.37