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(26.133,25.979,25.541,25.308,25.663,25.78,25.328,24.806,24.651,24.531,24.633,25.174,24.449,24.277,24.393,24.301,24.381,24.286,24.335,24.273,24.556,24.841,25.464,25.514,25.531,25.042,24.676,24.809,25.313,25.64,25.447,25.021,24.752,24.939,25.365,25.214,25.563,25.475,25.659,25.841,25.888,25.759,25.944,25.818,25.789,25.662,26.927,27.521,27.485,27.444,27.395,27.45,27.437,27.45,27.458,27.816,27.599,27.588,27.667,27.64) > 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/1l9hk1445596596.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/2uj3p1445596596.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/3w6dm1445596596.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.93134516 0.84570488 0.77760514 0.73161565 0.68399836 [7] 0.63557645 0.56990418 0.49754490 0.42790257 0.36583355 0.30431259 [13] 0.23394706 0.15595618 0.08465019 0.05201198 0.03686921 0.03180436 [19] 0.01564618 -0.02052949 -0.07243835 -0.11397965 -0.12574135 -0.12578380 [25] -0.13600312 -0.15449064 -0.18995081 -0.21249506 -0.22207288 -0.24099305 [31] -0.27500255 -0.31185585 -0.33749222 -0.34594933 -0.35076602 -0.35252443 [37] -0.37029785 -0.39412964 -0.41499036 -0.41782953 -0.40366544 -0.36935985 [43] -0.33510361 -0.30807219 -0.27983035 -0.24474530 -0.20342406 -0.16358552 [49] -0.13278525 > (mypacf <- c(rpacf$acf)) [1] 0.931345159 -0.163646641 0.104446670 0.097463834 -0.063482118 [6] 0.007562597 -0.154905979 -0.064390848 -0.038391443 -0.037283622 [11] -0.050367076 -0.113309633 -0.083518499 -0.009237430 0.216400561 [16] 0.036051278 0.116164459 -0.026628300 -0.140215784 -0.131633609 [21] -0.071731219 0.102626552 -0.008656046 -0.052743474 -0.020108392 [26] -0.205844690 0.058905437 -0.010041060 -0.074809336 -0.025924655 [31] -0.009980874 0.032930993 -0.014766097 -0.113883162 0.017051186 [36] -0.082483957 0.009279237 -0.002720271 0.037721407 -0.015058524 [41] 0.154751445 0.018230990 -0.003114019 0.059044158 -0.023889163 [46] 0.044454175 -0.045859007 -0.048806633 > 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/49xwg1445596596.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/5l0471445596596.tab") > > try(system("convert tmp/1l9hk1445596596.ps tmp/1l9hk1445596596.png",intern=TRUE)) character(0) > try(system("convert tmp/2uj3p1445596596.ps tmp/2uj3p1445596596.png",intern=TRUE)) character(0) > try(system("convert tmp/3w6dm1445596596.ps tmp/3w6dm1445596596.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.095 0.252 1.360