R version 3.1.0 (2014-04-10) -- "Spring Dance" Copyright (C) 2014 The R Foundation for Statistical Computing 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(83.5,83.6,83.9,83.9,84.2,84.4,84.6,84.8,84.8,84.9,85,85.1,85.3,85.5,86.1,86.2,86.3,86.5,86.5,86.6,86.8,87.3,87.7,87.8,88.1,88.8,89.3,89.2,89.3,89.6,89.6,89.9,90.2,90.2,90.4,90.5,91.5,91.5,91.8,92.2,92.4,92.7,93.1,93.1,93.5,93.9,94.3,94.7,95.3,95.9,96.2,96.7,96.7,96.9,97.3,97.4,97.9,98.4,98.4,98.8,98.9,98.9,99.3,99.4,99.7,99.8,99.7,99.9,100.4,101.1,101.3,101.4,101.8,102.2,102.4,102.5,102.8,103,103.2,103.2,103.6,103.7,103.7,103.8,104.2,104.5,104.5,104.8,105.2,105.3,105.5,105.4,105.7,106.8,106.8,107) > 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/1e2h71400672660.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/2bkw51400672660.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/3dmuc1400672660.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.97195201 0.94350336 0.91471112 0.88736328 0.86033237 [7] 0.83233574 0.80424911 0.77583144 0.74720410 0.71849542 0.68891377 [13] 0.65918229 0.62973531 0.59993772 0.57057788 0.54054895 0.51075014 [19] 0.48044772 0.44966679 0.41861629 0.38760924 0.35695662 0.32675707 [25] 0.29671135 0.26723143 0.23856685 0.21064252 0.18339054 0.15666646 [31] 0.13032543 0.10298428 0.07565991 0.04894007 0.02163763 -0.00512011 [37] -0.03233019 -0.05790643 -0.08333235 -0.10875362 -0.13279718 -0.15585349 [43] -0.17853498 -0.20008763 -0.22185467 -0.24349030 -0.26367583 -0.28282291 [49] -0.30026711 > (mypacf <- c(rpacf$acf)) [1] 0.9719520086 -0.0214673705 -0.0208026435 0.0111852948 -0.0090924382 [6] -0.0324297097 -0.0160691057 -0.0210228916 -0.0205661943 -0.0179857997 [11] -0.0324780816 -0.0202574518 -0.0124603109 -0.0251730984 -0.0109118058 [16] -0.0300851514 -0.0154083350 -0.0284833894 -0.0293034046 -0.0261529432 [21] -0.0207567298 -0.0165530121 -0.0146192890 -0.0196970098 -0.0125827400 [26] -0.0076700368 -0.0096767448 -0.0107409373 -0.0123738515 -0.0160894088 [31] -0.0414065882 -0.0245947201 -0.0143805061 -0.0378360194 -0.0176624137 [36] -0.0347515980 0.0009613900 -0.0252062724 -0.0284919851 -0.0029410757 [41] -0.0094326407 -0.0228782052 -0.0077653534 -0.0314152166 -0.0283659413 [46] -0.0026433164 -0.0115657186 0.0005559944 > 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/4vtm91400672660.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/5i73h1400672660.tab") > > try(system("convert tmp/1e2h71400672660.ps tmp/1e2h71400672660.png",intern=TRUE)) character(0) > try(system("convert tmp/2bkw51400672660.ps tmp/2bkw51400672660.png",intern=TRUE)) character(0) > try(system("convert tmp/3dmuc1400672660.ps tmp/3dmuc1400672660.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.682 0.316 1.989