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(93.61,93.17,91.60,90.30,90.88,91.06,92.05,95.29,96.44,96.49,96.52,96.09,99.16,98.09,99.41,99.87,100.06,99.65,99.92,98.44,102.64,112.33,115.63,118.29,121.43,129.96,147.73,154.10,150.09,144.14,141.54,136.68,129.32,118.99,109.61,106.22,104.97,102.45,101.91,101.77,102.67,103.45,101.41,102.45,102.17,101.40,101.68,100.61,97.93,98.30,99.79,101.62,101.55,102.43,102.09,102.01,102.26,101.24,100.91,100.67,100.33,99.99,99.23,98.17,97.38,96.70,98.65,100.68,101.07,101.12,101.13,99.88,99.20,99.91,103.62,108.05,113.96,117.39,126.04,139.67,145.04,142.37,137.72,132.46) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > 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/wessaorg/rcomp/tmp/1167w1389308891.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/wessaorg/rcomp/tmp/25fm21389308891.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/wessaorg/rcomp/tmp/3ivx31389308891.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.00000000 0.94680199 0.84067674 0.70737851 0.56036826 0.41153969 [7] 0.27108433 0.14661508 0.04871462 -0.02165447 -0.07567093 -0.11774865 [13] -0.15179271 -0.17821633 -0.20336997 -0.22927956 -0.25481273 -0.27619169 [19] -0.29311202 -0.30683657 -0.32259043 -0.33581477 -0.33816972 -0.33257406 [25] -0.32307412 -0.31082749 -0.29354703 -0.26503352 -0.23289305 -0.20472330 [31] -0.18417139 -0.16689807 -0.15082090 -0.13775477 -0.12775056 -0.12084476 [37] -0.11536054 -0.11207772 -0.10868195 -0.10288525 -0.09669291 -0.08824757 [43] -0.07344740 -0.05395731 -0.02369440 0.01843866 0.07445190 0.14345555 [49] 0.21726779 > (mypacf <- c(rpacf$acf)) [1] 0.946801985 -0.538374165 -0.100118080 -0.096509801 -0.039047416 [6] -0.012031672 0.001192986 0.085536451 0.005813621 -0.120377604 [11] -0.043003397 -0.055995838 -0.004254133 -0.091706554 -0.040240297 [16] -0.017324440 -0.006607084 -0.051498830 -0.060394348 -0.116760953 [21] -0.002073961 0.042222369 -0.056992147 -0.059517319 -0.037937752 [26] -0.005141245 0.054887818 -0.110936018 -0.072509212 -0.076462851 [31] -0.002895244 -0.030290092 -0.061141555 -0.018168609 -0.057886792 [36] -0.077517649 -0.096499992 -0.034082220 0.002677971 -0.096937478 [41] -0.055573444 0.005029511 -0.028027369 0.068566601 0.003345909 [46] 0.068050743 0.080811160 0.011319319 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/423r51389308892.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/wessaorg/rcomp/tmp/5yghk1389308892.tab") > > try(system("convert tmp/1167w1389308891.ps tmp/1167w1389308891.png",intern=TRUE)) character(0) > try(system("convert tmp/25fm21389308891.ps tmp/25fm21389308891.png",intern=TRUE)) character(0) > try(system("convert tmp/3ivx31389308891.ps tmp/3ivx31389308891.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.083 0.609 3.661