R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-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(48.74,48.79,48.82,48.82,49.20,49.30,49.30,49.34,49.47,49.65,49.70,49.75,49.75,49.70,50.09,50.19,50.53,50.55,50.55,50.55,50.58,50.61,50.94,51.01,51.01,51.04,51.15,51.31,51.31,51.34,51.34,51.34,51.47,51.95,51.97,51.92,51.92,51.91,51.97,52.14,52.33,52.40,52.40,52.41,52.71,53.17,53.33,53.32,53.32,53.30,53.31,53.72,53.87,53.91,53.91,53.96,54.02,54.33,54.48,54.54,52.40,52.45,52.38,52.45,52.83,52.76,52.86,52.88,53.32,53.20,53.22,53.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/wessaorg/rcomp/tmp/1mfd01413711974.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/2o0z51413711974.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/33w101413711974.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.0164618435 -0.0159130013 -0.1566122801 -0.1171992570 [6] 0.0588453183 0.0810917454 0.0743168694 -0.1776789610 -0.1061280703 [11] 0.0205852091 0.1000319335 0.0887264340 0.0668734047 -0.0745013757 [16] -0.1754093378 -0.1093887952 0.0497711462 0.0793188492 0.0424938775 [21] -0.0770224662 -0.0828041021 0.0020631819 0.0617676389 0.0680573804 [26] 0.0473840752 -0.0094740701 -0.1785285415 -0.0142069717 0.0630352607 [31] 0.0408756730 0.0409289312 0.0002886387 -0.0653523694 -0.0293197613 [36] 0.0688768848 0.0368743374 0.0188764301 -0.1136595870 -0.0086681235 [41] 0.0064948160 0.0605097202 0.0487646191 0.0185757074 -0.1033105938 [46] -0.0281802824 -0.1079312472 0.0469335235 0.0336961027 > (mypacf <- c(rpacf$acf)) [1] 0.016461843 -0.016188381 -0.156162824 -0.115497291 0.057652207 [6] 0.055635260 0.041145261 -0.180866204 -0.077690633 0.054489924 [11] 0.065125364 0.012989375 0.064683237 -0.021631935 -0.127592674 [16] -0.125648219 0.009183140 0.030907873 0.009848506 -0.071570071 [21] -0.022607169 0.033771198 -0.008711042 -0.040342691 0.051465014 [26] 0.071394145 -0.136964400 -0.021734473 0.060069037 -0.018948073 [31] -0.025734547 0.025692152 0.006631191 0.009059307 -0.009637459 [36] -0.038651107 0.043786437 -0.079028718 0.005138824 0.059904657 [41] 0.048263392 -0.039771584 0.001888693 -0.064158392 0.022515132 [46] -0.147127741 -0.001647105 0.030568895 > 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/4wdzx1413711974.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/5qugp1413711974.tab") > > try(system("convert tmp/1mfd01413711974.ps tmp/1mfd01413711974.png",intern=TRUE)) character(0) > try(system("convert tmp/2o0z51413711974.ps tmp/2o0z51413711974.png",intern=TRUE)) character(0) > try(system("convert tmp/33w101413711974.ps tmp/33w101413711974.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.166 0.189 1.363