R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(34.74,34.89,34.98,34.93,35.01,35.03,35.03,34.98,34.92,35.04,35.21,35.21,35.21,35.26,35.45,35.53,35.53,35.57,35.57,35.57,35.63,35.92,36.05,36.1,36.1,36.02,36.07,36.17,36.52,36.49,36.49,36.48,36.62,36.63,36.7,36.7,36.7,36.69,36.86,36.85,36.83,36.88,36.88,36.92,36.93,37.06,37.1,37.09,37.09,37.15,37.27,37.43,37.42,37.4,37.4,37.39,37.42,37.7,37.85,37.88) > 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/1xxdv1333542739.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/2cytm1333542739.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/3tjsd1333542739.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.00000000 0.94333535 0.88792397 0.83942440 0.79890767 0.75959316 [7] 0.71779317 0.67134454 0.61776917 0.55912420 0.50821754 0.46452176 [13] 0.41967170 0.37131010 0.32043992 0.27507222 0.23584442 0.19585262 [19] 0.15480756 0.11066410 0.06516095 0.01969570 -0.01768710 -0.04757087 [25] -0.07926582 -0.11357857 -0.15149597 -0.18657702 -0.21955544 -0.23877632 [31] -0.26291402 -0.29009900 -0.32034531 -0.33496029 -0.34621120 -0.35446569 [37] -0.36704050 -0.38320047 -0.40057402 -0.40848002 -0.40743847 -0.40600533 [43] -0.40420441 -0.40321133 -0.40081323 -0.39932610 -0.39165273 -0.37678961 [49] -0.36190482 > (mypacf <- c(rpacf$acf)) [1] 0.943335352 -0.017777335 0.033554840 0.047363457 -0.006766949 [6] -0.036530285 -0.060638653 -0.094004986 -0.088528789 0.018529673 [11] 0.019311871 -0.038841125 -0.047154341 -0.044704984 0.015525258 [16] 0.018600594 -0.043266791 -0.044285229 -0.058128142 -0.045120485 [21] -0.045305878 0.016398834 0.017172067 -0.041989593 -0.032066173 [26] -0.058111833 -0.023217207 -0.040192412 0.071420399 -0.083105516 [31] -0.052286056 -0.050096356 0.101385266 -0.014882576 -0.009153846 [36] -0.065730479 -0.055883725 -0.034487544 0.043081548 0.017653621 [41] -0.048411571 -0.005438755 0.006255005 0.012152185 -0.049390652 [46] 0.002640769 0.024634100 -0.002401105 > 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/4tai91333542740.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/5wqpk1333542740.tab") > > try(system("convert tmp/1xxdv1333542739.ps tmp/1xxdv1333542739.png",intern=TRUE)) character(0) > try(system("convert tmp/2cytm1333542739.ps tmp/2cytm1333542739.png",intern=TRUE)) character(0) > try(system("convert tmp/3tjsd1333542739.ps tmp/3tjsd1333542739.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.948 0.189 1.147