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.07,2.08,2.08,2.08,2.09,2.09,2.09,2.1,2.1,2.1,2.11,2.11,2.11,2.13,2.18,2.2,2.21,2.21,2.22,2.22,2.23,2.23,2.23,2.23,2.24,2.25,2.26,2.27,2.28,2.29,2.3,2.3,2.3,2.32,2.32,2.32,2.33,2.34,2.34,2.34,2.35,2.35,2.36,2.37,2.37,2.37,2.38,2.38,2.38,2.39,2.4,2.41,2.42,2.43,2.43,2.43,2.43,2.44,2.44,2.45,2.45,2.48,2.49,2.49,2.5,2.51,2.52,2.53,2.54,2.54,2.56,2.56) > 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/1lzdl1352718494.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/2x5vw1352718494.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/30bkk1352718494.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.150396076 -0.054877950 -0.023897682 0.035146734 [6] -0.204491554 -0.037486085 -0.100434797 -0.197747770 0.016222190 [11] 0.014270042 -0.014314409 -0.064662891 0.130406724 -0.012438895 [16] 0.080969782 0.024321185 -0.046359486 -0.062343707 0.104661762 [21] -0.059947889 -0.096264298 -0.010587580 -0.006239614 -0.001891648 [26] -0.078872433 0.020836358 -0.096808802 0.070196667 0.007247955 [31] -0.116697320 -0.106049239 0.040624042 0.018339706 -0.072673152 [36] 0.053667941 0.092380169 0.137392511 -0.014616911 0.044427504 [41] -0.113882032 -0.062569576 -0.064521724 0.014854880 -0.082458093 [46] 0.003218624 0.041930852 0.168271946 0.070958973 > (mypacf <- c(rpacf$acf)) [1] 0.150396076 -0.079290398 -0.003155639 0.036213241 -0.224699421 [6] 0.040436185 -0.137415598 -0.188988944 0.098150832 -0.105312234 [11] 0.005067599 -0.092551110 0.061493939 -0.044181438 0.051931956 [16] -0.016868899 -0.089464942 0.006485641 0.070071392 -0.103496587 [21] -0.006047022 -0.042939943 -0.013231037 0.025317334 -0.153019047 [26] 0.045254410 -0.119419249 0.039036264 -0.033967708 -0.226623498 [31] 0.006105796 -0.101589353 -0.005947643 -0.120281139 -0.043560233 [36] 0.122070610 -0.003241650 -0.088292051 0.013736324 -0.159207327 [41] -0.017917456 -0.132740793 -0.005866483 -0.053150220 -0.075758862 [46] 0.042045508 0.059447498 -0.056281822 > 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/4avrh1352718494.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/5hctv1352718494.tab") > > try(system("convert tmp/1lzdl1352718494.ps tmp/1lzdl1352718494.png",intern=TRUE)) character(0) > try(system("convert tmp/2x5vw1352718494.ps tmp/2x5vw1352718494.png",intern=TRUE)) character(0) > try(system("convert tmp/30bkk1352718494.ps tmp/30bkk1352718494.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.050 0.329 2.360