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(7.72,7.67,7.84,7.79,7.83,7.94,8.02,8.06,8.12,8.13,7.97,8.01,8,7.9,7.99,8.02,8.08,8.02,8.07,8.11,8.19,8.16,8.08,8.22,8.15,8.19,8.31,8.3,8.34,8.31,8.38,8.34,8.44,8.64,8.6,8.61,8.54,8.69,8.73,8.91,9.01,9.08,8.94,9.03,9.02,8.96,9.03,8.94,8.95,8.95,8.99,8.93,8.98,8.95,9.02,8.92,9.1,9.06,8.97,8.89,8.99,8.79,8.83,8.61,8.71,8.91,8.91,8.89,8.98,9,8.99,8.88) > 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/1o87o1352746685.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/2ymhk1352746685.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/3tq691352746685.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.950538959 0.903678618 0.861611645 0.817491735 [6] 0.773839630 0.740243871 0.708514911 0.685405534 0.666006049 [11] 0.640922288 0.605342100 0.566979796 0.525826433 0.473943394 [16] 0.420460156 0.370302781 0.326009792 0.273023690 0.225660689 [21] 0.175938774 0.137888673 0.089725974 0.045417013 0.007998454 [26] -0.032899761 -0.077295411 -0.113667863 -0.154970598 -0.194817282 [31] -0.233298220 -0.269663339 -0.307409171 -0.340989058 -0.358993467 [36] -0.379023790 -0.397930860 -0.422645661 -0.440817222 -0.455877986 [41] -0.457215204 -0.446850170 -0.434648774 -0.432113970 -0.418938893 [46] -0.405643173 -0.396334893 -0.380570265 -0.366450538 > (mypacf <- c(rpacf$acf)) [1] 0.950538959 0.001599436 0.025742016 -0.041446352 -0.018047955 [6] 0.078302623 0.005565984 0.081327948 0.027160382 -0.061642487 [11] -0.118882233 -0.059781644 -0.044778511 -0.130029096 -0.061264948 [16] -0.029236621 0.010087672 -0.153357646 -0.020359431 -0.085033288 [21] 0.084177924 -0.142854409 0.009986579 0.060381509 -0.070607199 [26] -0.060221986 0.031595046 -0.045814452 -0.021724062 -0.056967766 [31] 0.003528991 -0.040209943 -0.031183979 0.100793324 -0.011948222 [36] -0.021443538 -0.125769887 0.017240096 0.066776840 0.108655802 [41] 0.164479342 0.029562294 -0.106906451 0.050984707 0.006392646 [46] 0.005755000 0.124103507 -0.058014308 > 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/4hw2q1352746685.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/5f7cd1352746685.tab") > > try(system("convert tmp/1o87o1352746685.ps tmp/1o87o1352746685.png",intern=TRUE)) character(0) > try(system("convert tmp/2ymhk1352746685.ps tmp/2ymhk1352746685.png",intern=TRUE)) character(0) > try(system("convert tmp/3tq691352746685.ps tmp/3tq691352746685.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.913 0.331 2.282