R version 2.15.3 (2013-03-01) -- "Security Blanket" Copyright (C) 2013 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(8.5,8.5,8.5,8.6,8.6,8.4,8.2,8,8,8,8,7.9,7.9,7.9,7.9,8,7.9,7.4,7.2,7,6.9,7.1,7.2,7.2,7.1,6.9,6.8,6.8,6.8,6.9,7.1,7.2,7.2,7.1,7.1,7.2,7.5,7.7,7.8,7.7,7.7,7.8,8,8.1,8.1,8,8.1,8.2,8.4,8.5,8.5,8.5,8.5,8.5,8.4,8.3,8.2,8.1,7.9,7.6,7.3,7.1,7,7.1,7.1,7.1,7.3,7.3,7.3,7.2,7.2,7.1) > 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/124sm1363356303.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/27qdc1363356303.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/3uze41363356303.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.5883974034 0.2053360331 -0.0576407706 -0.1254801536 [6] 0.0423041420 0.2221391776 0.1572596254 0.0744096716 -0.0024149123 [11] -0.0237426674 -0.0045841646 -0.0004362326 -0.0488252985 -0.0311467111 [16] 0.0135931870 -0.0738022214 -0.1252568264 -0.1586353214 -0.1334514486 [21] -0.0421999226 -0.0529568532 -0.1222761516 -0.2741535896 -0.3059464610 [26] -0.2146949349 -0.0348598994 0.0413810559 0.0110680999 -0.1723103951 [31] -0.2160482982 -0.2192999434 -0.0769913349 0.0307506774 0.0815159456 [36] 0.0242473871 0.0075707947 -0.0196766221 -0.0064377810 0.0187460918 [41] 0.0409701337 0.0452237739 0.0990545812 0.1033082214 0.0729952655 [46] 0.0516675103 -0.0612035851 -0.0450049132 -0.0167555013 > (mypacf <- c(rpacf$acf)) [1] 5.883974e-01 -2.154756e-01 -1.246457e-01 2.195845e-02 2.244257e-01 [6] 1.208005e-01 -1.836921e-01 5.719380e-02 6.019943e-02 1.764546e-02 [11] -7.917879e-02 -4.807828e-02 -2.167108e-02 6.420188e-02 2.608110e-02 [16] -2.444878e-01 -2.556374e-02 2.139710e-02 4.035455e-02 -5.616370e-02 [21] -1.920005e-01 1.146595e-05 -1.876705e-01 7.798434e-03 -4.617307e-02 [26] 6.615625e-02 -3.892399e-02 -3.066412e-02 -1.853801e-01 4.184232e-02 [31] -6.316618e-02 5.309945e-02 -3.041138e-02 1.176019e-02 -3.393536e-02 [36] 5.618968e-02 -4.489192e-02 8.223589e-03 -2.781707e-02 -3.018848e-03 [41] -4.007136e-02 5.646148e-02 5.919813e-03 -1.522875e-02 -4.827449e-02 [46] -2.243318e-01 5.388423e-02 -1.081827e-01 > 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/4hh0e1363356303.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/5kd821363356303.tab") > > try(system("convert tmp/124sm1363356303.ps tmp/124sm1363356303.png",intern=TRUE)) character(0) > try(system("convert tmp/27qdc1363356303.ps tmp/27qdc1363356303.png",intern=TRUE)) character(0) > try(system("convert tmp/3uze41363356303.ps tmp/3uze41363356303.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.856 0.280 2.115