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(124275,58605,21828,42811,65963,128457,26867,143540,107458,258558,22475,294584,159848,289458,117950,78351,84589,44324,52285,185486,23846,13257,166999,148488,74747,55700,218584,187888,44788,18840,48787,69100,41892,90588,148574,50201,86828,102785,118844,145288,56790,287525,187880,87740,55258,58769,43366,77051,91574,15533,18425,65192,81059,73322,91261,86166,61842,25192,21059,15855,12618,101667,224275,55700,60748,41848,61781,120077,42032,46485,36861,55027,48999,68352,126987,86526,125340,69029,153287,135724,92108,119906,79798,97206) > 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/1rus91352710439.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/28dmu1352710439.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/3vtjf1352710439.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.175832181 0.166739227 0.007081129 0.178536659 [6] -0.063432235 -0.095865698 -0.042189589 -0.020958222 -0.179475445 [11] -0.073355048 0.021724163 -0.011040657 0.042090987 0.222748353 [16] 0.222926263 -0.061690494 -0.091792765 -0.063072686 0.011523760 [21] -0.029981839 -0.052451067 -0.023115553 -0.046363270 -0.138503855 [26] 0.020243123 0.044517877 -0.017877837 0.170821623 0.089318623 [31] 0.095086863 -0.097770550 -0.019944477 -0.042718449 -0.024799171 [36] -0.024526104 -0.018287098 -0.068160128 -0.108873244 -0.037270919 [41] 0.012876541 -0.050610734 -0.022379103 0.018292356 -0.069156674 [46] -0.087841669 -0.148215019 -0.088353793 -0.014383750 > (mypacf <- c(rpacf$acf)) [1] 0.175832181 0.140155451 -0.045020662 0.169633520 -0.121242333 [6] -0.125891867 0.035063409 -0.027896080 -0.163654755 0.027455195 [11] 0.072278838 -0.050987783 0.109176450 0.234188166 0.078150526 [16] -0.201435122 -0.115565015 -0.110369760 0.007357044 0.147943491 [21] 0.002158263 -0.030631425 0.021505541 -0.124650564 0.029160735 [26] 0.075004302 -0.118873345 0.185909145 0.001919553 -0.012050425 [31] 0.018800888 -0.027202158 -0.123838464 -0.053961854 0.077764715 [36] -0.018209581 0.024067502 0.020094887 -0.049163216 -0.051984008 [41] -0.064989573 -0.103946196 -0.046042821 -0.036868287 -0.029500729 [46] -0.019035158 -0.038637255 0.031817390 > 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/4lah01352710439.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/5vc3l1352710439.tab") > > try(system("convert tmp/1rus91352710439.ps tmp/1rus91352710439.png",intern=TRUE)) character(0) > try(system("convert tmp/28dmu1352710439.ps tmp/28dmu1352710439.png",intern=TRUE)) character(0) > try(system("convert tmp/3vtjf1352710439.ps tmp/3vtjf1352710439.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.131 0.431 2.542