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(2.1,2.1,2.11,2.12,2.13,2.13,2.13,2.13,2.14,2.15,2.16,2.17,2.16,2.2,2.19,2.2,2.2,2.2,2.21,2.22,2.25,2.33,2.33,2.35,2.37,2.38,2.38,2.41,2.41,2.41,2.41,2.42,2.42,2.43,2.44,2.44,2.43,2.44,2.44,2.44,2.44,2.44,2.43,2.42,2.43,2.43,2.43,2.43,2.43,2.44,2.43,2.43,2.44,2.43,2.43,2.44,2.46,2.48,2.49,2.5,2.53,2.55,2.57,2.56,2.56,2.57,2.56,2.57,2.58,2.58,2.58,2.59) > 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/1jml71353967252.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/26mpr1353967252.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/3wznx1353967252.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.094501084 0.157114687 0.173990691 0.066537728 [6] -0.023307334 0.105013806 -0.038191788 0.093028214 -0.223142808 [11] 0.078680587 0.022226120 0.006248355 -0.001569650 -0.043315076 [16] -0.221736474 -0.047140909 -0.068379571 -0.066749434 -0.131363660 [21] -0.121573763 -0.098363209 -0.145369533 -0.049365335 0.003263299 [26] -0.048467096 -0.113081322 -0.055191791 0.030290612 -0.092945044 [31] -0.094213769 0.059875033 -0.126706125 -0.010731989 0.067127480 [36] 0.099249351 0.146080261 0.071481066 0.057865337 0.112856007 [41] 0.055864714 0.118478317 -0.080986672 -0.089878329 0.026095806 [46] -0.114210926 -0.033989421 0.089607648 -0.033091182 > (mypacf <- c(rpacf$acf)) [1] 0.094501084 0.149519510 0.151957299 0.021736048 -0.080358100 [6] 0.076566775 -0.051164223 0.095046199 -0.266511463 0.114562479 [11] 0.055480988 0.046181620 -0.019472687 -0.134283075 -0.172781233 [16] -0.038467339 0.083124570 -0.073177875 -0.082187320 -0.114793275 [21] 0.006615969 -0.082819819 0.013214534 -0.042791127 0.014223820 [26] -0.069636130 -0.044852747 0.078324183 -0.153640809 -0.110507263 [31] 0.032593790 -0.049705165 0.027467998 0.024156650 0.056113195 [36] 0.102208261 -0.004703059 -0.045721944 -0.007065646 0.073766860 [41] 0.004800359 -0.197060494 -0.128737809 0.014809961 -0.077699403 [46] -0.016915181 0.001338889 -0.039922927 > 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/4h5381353967252.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/5k3dc1353967252.tab") > > try(system("convert tmp/1jml71353967252.ps tmp/1jml71353967252.png",intern=TRUE)) character(0) > try(system("convert tmp/26mpr1353967252.ps tmp/26mpr1353967252.png",intern=TRUE)) character(0) > try(system("convert tmp/3wznx1353967252.ps tmp/3wznx1353967252.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.007 0.373 2.357