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(106.68,109.73,108.06,111.33,105.66,103.65,100.34,100.56,102.67,101.5,102.35,104.98,106.31,103.73,106.62,108.54,105.12,105.29,104.62,104.34,108.23,107.6,106.87,107.96,108.34,109.04,106.95,105.59,108.08,108.48,106.84,105.6,106.9,106.84,106.81,106.98,107.53,107.37,106.98,108.94,106.38,109.02,106.53,105.02,109.7,108.39,110.18,109.54,109.1,110.85,112.23,110.58,110.77,108.08,108.05,108.87,109.61,111.27,107.61,110.98,106.63,106.83,108.77,106.12,106.8,106.34,105.16,107.97,106.76,108.78,105.58,109.22) > 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/1h89g1353079021.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/2huln1353079021.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/399ym1353079021.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.0000000000 -0.3910761056 0.0757890229 0.0128268622 -0.1829396508 [6] 0.1550413120 -0.1485355296 -0.0212722704 -0.0086855338 -0.0124297329 [11] 0.0622560844 -0.0699506469 0.1193151851 0.0431805459 -0.1073919281 [16] -0.0076371393 -0.0885446466 0.0259515423 0.0878318276 -0.1710904335 [21] 0.0152930462 0.1228004074 -0.0424317387 0.0143395253 -0.0060733231 [26] 0.0283861378 -0.0214815771 0.1192311981 -0.0989638954 -0.0109713105 [31] 0.0673404007 -0.0798337186 0.0174932750 -0.0230994342 0.0474326683 [36] -0.0330241006 0.1082920400 -0.0469549465 0.0255306283 0.0197743714 [41] -0.1417244603 0.0157451937 -0.0119097896 -0.0099088994 0.0227124390 [46] -0.0136023703 -0.1015959026 0.1527953575 -0.0008204537 > (mypacf <- c(rpacf$acf)) [1] -0.391076106 -0.091081558 0.011363738 -0.198232452 0.008573802 [6] -0.102761950 -0.143084573 -0.131174890 -0.058251931 -0.018609415 [11] -0.092807841 0.047133721 0.116864771 -0.069618130 -0.133686225 [16] -0.131069757 -0.081846742 0.042051644 -0.144526279 -0.190753823 [21] 0.037580215 -0.017416231 -0.144656442 -0.087855844 -0.002050765 [26] -0.091950889 0.105455957 0.032883279 -0.058165993 -0.031562227 [31] -0.025002820 -0.024331802 -0.071069811 -0.010221298 -0.065739010 [36] 0.124528983 0.081241401 0.023318596 -0.038470587 -0.093071080 [41] -0.054684598 -0.030053154 -0.003163351 -0.002828669 -0.025513840 [46] -0.192664008 0.008260438 -0.034860436 > 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/4muw91353079021.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/5dc0o1353079022.tab") > > try(system("convert tmp/1h89g1353079021.ps tmp/1h89g1353079021.png",intern=TRUE)) character(0) > try(system("convert tmp/2huln1353079021.ps tmp/2huln1353079021.png",intern=TRUE)) character(0) > try(system("convert tmp/399ym1353079021.ps tmp/399ym1353079021.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.772 0.452 2.210