## Bayesian Computation with RThere has been a dramatic growth in the development and application of Bayesian inferential methods. Some of this growth is due to the availability of powerful simulation-based algorithms to summarize posterior distributions. There has been also a growing interest in the use of the system R for statistical analyses. R's open source nature, free availability, and large number of contributor packages have made R the software of choice for many statisticians in education and industry. Bayesian Computation with R introduces Bayesian modeling by the use of computation using the R language. The early chapters present the basic tenets of Bayesian thinking by use of familiar one and two-parameter inferential problems. Bayesian computational methods such as Laplace's method, rejection sampling, and the SIR algorithm are illustrated in the context of a random effects model. The construction and implementation of Markov Chain Monte Carlo (MCMC) methods is introduced. These simulation-based algorithms are implemented for a variety of Bayesian applications such as normal and binary response regression, hierarchical modeling, order-restricted inference, and robust modeling. Algorithms written in R are used to develop Bayesian tests and assess Bayesian models by use of the posterior predictive distribution. The use of R to interface with WinBUGS, a popular MCMC computing language, is described with several illustrative examples. This book is a suitable companion book for an introductory course on Bayesian methods and is valuable to the statistical practitioner who wishes to learn more about the R language and Bayesian methodology. The LearnBayes package, written by the author and available from the CRAN website, contains all of the R functions described in the book. The second edition contains several new topics such as the use of mixtures of conjugate priors and the use of Zellnera (TM)s g priors to choose between models in linear regression. There are more illustrations of the construction of informative prior distributions, such as the use of conditional means priors and multivariate normal priors in binary regressions. The new edition contains changes in the R code illustrations according to the latest edition of the LearnBayes package. |

### What people are saying - Write a review

### Contents

An Introduction to R | 1 |

122 Reading the Data into R | 2 |

124 R Commands to Compare Batches | 4 |

125 R Commands for Studying Relationships | 6 |

13 Exploring the Robustness of the t Statistic | 8 |

132 Writing a Function to Compute the t Statistic | 9 |

133 Programming a Monte Carlo Simulation | 11 |

134 The Behavior of the True Signiﬁcance Level Under Different Assumptions | 12 |

613 Exercises | 131 |

Hierarchical Modeling | 136 |

73 Individual and Combined Estimates | 139 |

74 Equal Mortality Rates? | 141 |

75 Modeling a Prior Belief of Exchangeability | 145 |

76 Posterior Distribution | 147 |

78 Posterior Inferences | 151 |

781 Shrinkage | 152 |

14 Further Reading | 13 |

15 Summary of R Functions | 14 |

16 Exercises | 15 |

Introduction to Bayesian Thinking | 19 |

23 Using a Discrete Prior | 20 |

24 Using a Beta Prior | 22 |

25 Using a Histogram Prior | 26 |

26 Prediction | 29 |

27 Further Reading | 34 |

29 Exercises | 35 |

SingleParameter Models | 38 |

33 Estimating a Heart Transplant Mortality Rate | 41 |

34 An Illustration of Bayesian Robustness | 44 |

35 A Bayesian Test of the Fairness of a Coin | 50 |

36 Further Reading | 53 |

38 Exercises | 54 |

Multiparameter Models | 57 |

43 A Multinomial Model | 60 |

45 Comparing Two Proportions | 65 |

46 Further Reading | 70 |

48 Exercises | 71 |

Introduction to Bayesian Computation | 75 |

52 Computing Integrals | 76 |

53 Setting Up a Problem on R | 77 |

54 A BetaBinomial Model for Overdispersion | 78 |

55 Approximations Based on Posterior Modes | 80 |

56 The Example | 82 |

57 Monte Carlo Method for Computing Integrals | 84 |

58 Rejection Sampling | 85 |

59 Importance Sampling | 88 |

510 Sampling Importance Resampling | 91 |

511 Further Reading | 94 |

513 Exercises | 96 |

Markov Chain Monte Carlo Methods | 101 |

63 MetropolisHasting Algorithms | 104 |

64 Gibbs Sampling | 106 |

66 A Strategy in Bayesian Computing | 108 |

68 Example of Output Analysis | 113 |

69 Modeling Data with Cauchy Errors | 116 |

610 Analysis of the Stanford Heart Transplant Data | 124 |

611 Further Reading | 129 |

612 Summary of R Functions | 130 |

782 Comparing Hospitals | 153 |

79 Posterior Predictive Model Checking | 155 |

710 Further Reading | 157 |

711 Summary of R Functions | 158 |

Model Comparison | 163 |

83 A OneSided Test of a Normal Mean | 164 |

84 A TwoSided Test of a Normal Mean | 167 |

85 Comparing Two Models | 168 |

86 Models for Soccer Goals | 169 |

87 Is a Baseball Hitter Really Streaky? | 172 |

88 A Test of Independence in a TwoWay Contingency Table | 176 |

89 Further Reading | 180 |

810 Summary of R Functions | 181 |

811 Exercises | 183 |

Regression Models | 186 |

922 The Posterior Distribution | 188 |

924 Computation | 189 |

926 An Example | 190 |

93 Survival Modeling | 199 |

94 Further Reading | 204 |

95 Summary of R Functions | 205 |

96 Exercises | 206 |

Gibbs Sampling | 211 |

102 Robust Modeling | 212 |

103 Binary Response Regression with a Probit Link | 216 |

104 Estimating a Table of Means | 219 |

1042 A Flat Prior Over the Restricted Space | 223 |

1043 A Hierarchical Regression Prior | 227 |

1044 Predicting the Success of Future Students | 232 |

105 Further Reading | 233 |

107 Exercises | 234 |

Using R to Interface with WinBUGS | 237 |

112 An R Interface to WinBUGS | 238 |

113 MCMC Diagnostics Using the boa Package | 239 |

114 A ChangePoint Model | 240 |

115 A Robust Regression Model | 243 |

116 Estimating Career Trajectories | 247 |

117 Further Reading | 253 |

118 Exercises | 254 |

259 | |

263 | |