R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 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(103.43,103.49,103.5,103.5,103.5,103.5,103.54,103.71,103.76,103.76,103.76,103.82,105.11,105.58,105.91,105.92,105.92,105.92,105.96,105.98,105.98,105.98,106.01,106.01,106.91,107.11,107.18,107.2,107.35,107.35,107.35,107.52,107.56,107.55,107.6,107.6,110.04,110.27,110.33,110.33,110.33,110.33,110.33,110.35,110.38,110.54,110.54,110.54,110.54,106.74,106.78,106.75,106.75,106.75,106.82,107.08,107.25,107.28,107.28,107.28,108.44,109.33,109.44,109.44,109.45,109.45,109.45,109.45,109.46,109.46,109.46,109.46,110.95,110.95,110.95,110.95,110.95,110.95,110.95,110.95,110.97,110.97,110.97,111) > 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/18s4n1389455711.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/2r1mi1389455711.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/3yzs61389455711.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.943205723 0.881793912 0.818289679 0.754475981 [6] 0.690842519 0.625589371 0.561424349 0.499120337 0.436272957 [11] 0.372458720 0.307014688 0.246259134 0.204010706 0.183826310 [16] 0.165700946 0.147572494 0.128066532 0.107295152 0.086864504 [21] 0.064691823 0.041407283 0.018748413 -0.004903169 -0.014512482 [26] -0.020194729 -0.022763775 -0.025665878 -0.028611681 -0.029737341 [31] -0.030687381 -0.031950654 -0.032086235 -0.032819789 -0.034631047 [36] -0.035938274 -0.060258943 -0.069512655 -0.068760425 -0.067602665 [41] -0.065411212 -0.063224970 -0.061323781 -0.058813573 -0.056784344 [46] -0.055565892 -0.053134191 -0.051335609 -0.050463807 > (mypacf <- c(rpacf$acf)) [1] 0.943205723 -0.071066633 -0.050088328 -0.036401265 -0.034282813 [6] -0.052537688 -0.029176650 -0.024293954 -0.048064172 -0.052914756 [11] -0.060543840 -0.005537715 0.119782159 0.157409154 -0.020210456 [16] -0.034042336 -0.043964781 -0.044743424 -0.026635660 -0.037402080 [21] -0.038389005 -0.033956828 -0.052922501 0.104295910 0.052235469 [26] 0.071130729 0.017145156 -0.020409301 -0.016999188 -0.029932120 [31] -0.028210470 -0.015858469 -0.038403954 -0.044543541 -0.013501416 [36] -0.205984575 0.203475538 0.141425383 0.029049810 0.001718366 [41] -0.019462181 -0.034242180 -0.024068488 -0.018453775 -0.028460022 [46] -0.034082531 -0.053713630 -0.070642958 > 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/4rj7e1389455711.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/51rw71389455712.tab") > > try(system("convert tmp/18s4n1389455711.ps tmp/18s4n1389455711.png",intern=TRUE)) character(0) > try(system("convert tmp/2r1mi1389455711.ps tmp/2r1mi1389455711.png",intern=TRUE)) character(0) > try(system("convert tmp/3yzs61389455711.ps tmp/3yzs61389455711.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.583 0.515 3.065