beta<-mcmc.output graphics.off() #------------------------------------------------------------------------------- postscript('chap1_ex09_1.ps', width = 10.0, height = 12.0, horizontal=FALSE) par( mfrow=c(3,2), xaxs='r', yaxs='r', bty='l' , cex=0.8) iter<-55000 burnin<-15000 index<-seq(1,iter,50) index2<-(burnin+1):iter plot(index, beta[index,1], type='l', ylab='Values of beta0', xlab='Iterations', main='(a) Trace Plot of beta0') plot(index, beta[index,2], type='l', ylab='Values of beta1', xlab='Iterations', main='(b) Trace Plot of beta1') iter<-55000 burnin<-15000 index<-seq(1,iter,1) index2<-(burnin+1):iter ergbeta0<-erg.mean( beta[index,1] ) ergbeta02<-erg.mean( beta[index2,1] ) ylims0<-range( c(ergbeta0,ergbeta02) ) ergbeta1<-erg.mean( beta[index,2] ) ergbeta12<-erg.mean( beta[index2,2] ) ylims1<-range( c(ergbeta1,ergbeta12) ) step<-50 index3<-seq(1,iter,step) index4<-seq(burnin+1,iter,step) plot(index3 , ergbeta0[index3], type='l', ylab='Values of beta0', xlab='Iterations', main='(c) Ergodic Mean Plot of beta0', ylim=ylims0) lines(index4, ergbeta02[index4-burnin], col=2, lty=2) plot(index3, ergbeta1[index3], type='l', ylab='Values of beta1', xlab='Iterations', main='(d) Ergodic Mean Plot of beta1', ylim=ylims1) lines(index4, ergbeta12[index4-burnin], col=2, lty=2) lag.to.print<-900 acf1<-acf(beta[index2,1], main='Autocorrelations Plot for beta0', lag.max=lag.to.print, plot=FALSE) acf2<-acf(beta[index2,2], main='Autocorrelations Plot for beta1', lag.max=lag.to.print, plot=FALSE) acf.index<-seq(1,lag.to.print,20) plot( acf1[acf.index], main='Auto-correlations for beta0' ) plot( acf2[acf.index], main='Auto-correlations for beta1' ) graphics.off()