R version 3.2.2 (2015-08-14) -- "Fire Safety" Copyright (C) 2015 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-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(98.4,98.1,97.5,97.7,98.2,98.9,99.9,100.9,101.8,102.1,103.1,103.4,105.5,106.7,106.9,107.2,107.7,107.3,107.2,107.1,106.6,106.6,106.5,106.7,106.3,108.9,109.9,110.8,110.5,111.2,111.4,112.2,113.2,114,114.2,114.6,115.9,116.1,116.4,116.7,117.9,118.1,118.3,118.8,118.4,118,117.9,117.9,117.9,117.3,117.8,117.8,117.8,117.6,117.3,116.3,114.3,113.8,113.5,114.7) > 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/1z45c1445586975.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/2bgol1445586975.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/3cea11445586975.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.96276033 0.92007143 0.86901150 0.81541899 0.75714501 [7] 0.69862987 0.64157894 0.58550646 0.53225788 0.47870814 0.42936079 [13] 0.37854635 0.33679092 0.29851263 0.25999706 0.22054583 0.18292653 [19] 0.14265242 0.10072559 0.05659370 0.01105346 -0.03582763 -0.08350579 [25] -0.13071803 -0.17815503 -0.21449917 -0.24759588 -0.27719334 -0.30857439 [31] -0.33561666 -0.36119353 -0.38062590 -0.39660637 -0.40803388 -0.41848546 [37] -0.42330550 -0.42347075 -0.42230211 -0.42003204 -0.41574102 -0.40614143 [43] -0.39469749 -0.38128521 -0.36469957 -0.34727810 -0.33007074 -0.31225035 [49] -0.29265043 > (mypacf <- c(rpacf$acf)) [1] 0.9627603344 -0.0935256827 -0.1324963511 -0.0483417277 -0.0803741215 [6] -0.0250273023 -0.0021870088 -0.0219133009 0.0008655493 -0.0471874752 [11] 0.0133323174 -0.0627250845 0.0811049464 0.0078922077 -0.0659406595 [16] -0.0542011018 -0.0147483357 -0.0761303917 -0.0500334597 -0.0594638137 [21] -0.0477270650 -0.0590135557 -0.0435193701 -0.0440234943 -0.0462549636 [26] 0.1136178505 -0.0169358034 -0.0433056174 -0.0851384494 -0.0150230231 [31] -0.0401991558 0.0296641409 -0.0021210117 0.0020233831 -0.0547588939 [36] 0.0362080186 0.0057403694 0.0034429889 -0.0095250938 -0.0037339142 [41] 0.0193199221 0.0065903330 -0.0159531754 0.0286165608 -0.0222632989 [46] -0.0183856415 -0.0235992664 0.0145643549 > 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/4lhyf1445586975.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/5smqj1445586975.tab") > > try(system("convert tmp/1z45c1445586975.ps tmp/1z45c1445586975.png",intern=TRUE)) character(0) > try(system("convert tmp/2bgol1445586975.ps tmp/2bgol1445586975.png",intern=TRUE)) character(0) > try(system("convert tmp/3cea11445586975.ps tmp/3cea11445586975.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.115 0.202 1.323