人大经济论坛下载系统

Excel SPSS Eviews Stata SASS-Plus&R Matlab Lisrel&AMOS Gauss 其他
返回首页

Bayesian Computation with R

文件格式:Pdf 可复制性:可复制 TAG标签: R Bayesian Computation 点击次数: 更新时间:2009-10-14 12:57
介绍

Paperback: 280 pages

Publisher: Springer; 1 edition (July 31, 2007)

Language: English

ISBN-10: 0387713840

ISBN-13: 978-0387713847

Product Dimensions: 9.1 x 6.1 x 0.6 inches
Book Description

There 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. Also the book 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.

Contents
1 An Introduction to R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Exploring a Student Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2.1 Introduction to the Dataset . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2.2 Reading the Data into R . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.3 R Commands to Summarize and Graph a Single Batch . 2
1.2.4 R Commands to Compare Batches . . . . . . . . . . . . . . . . . . 4
1.2.5 R Commands for Studying Relationships . . . . . . . . . . . . . 6
1.3 Exploring the Robustness of the t Statistic . . . . . . . . . . . . . . . . . 8
1.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3.2 Writing a Function to Compute the t Statistic . . . . . . . . 9
1.3.3 Programming a Monte Carlo Simulation . . . . . . . . . . . . . . 11
1.3.4 The Behavior of the True Significance Level Under
Different Assumptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.4 Further Reading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.5 Summary of R Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2 Introduction to Bayesian Thinking. . . . . . . . . . . . . . . . . . . . . . . . . 19
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.2 Learning About the Proportion of Heavy Sleepers . . . . . . . . . . . 19
2.3 Using a Discrete Prior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.4 Using a Beta Prior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.5 Using a Histogram Prior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.6 Prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.7 Further Reading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.8 Summary of R Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
viii Contents
3 Single-Parameter Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.2 Normal Distribution with Known Mean
but Unknown Variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.3 Estimating a Heart Transplant Mortality Rate . . . . . . . . . . . . . . 41
3.4 An Illustration of Bayesian Robustness . . . . . . . . . . . . . . . . . . . . . 44
3.5 A Bayesian Test of the Fairness of a Coin. . . . . . . . . . . . . . . . . . . 50
3.6 Further Reading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.7 Summary of R Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
4 Multiparameter Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.2 Normal Data with Both Parameters Unknown . . . . . . . . . . . . . . 57
4.3 A Multinomial Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.4 A Bioassay Experiment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.5 Comparing Two Proportions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
4.6 Further Reading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.7 Summary of R Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
5 Introduction to Bayesian Computation . . . . . . . . . . . . . . . . . . . . 75
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.2 Computing Integrals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
5.3 Setting Up a Problem on R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
5.4 A Beta-Binomial Model for Overdispersion . . . . . . . . . . . . . . . . . 78
5.5 Approximations Based on Posterior Modes . . . . . . . . . . . . . . . . . 80
5.6 The Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
5.7 Monte Carlo Method for Computing Integrals . . . . . . . . . . . . . . . 84
5.8 Rejection Sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
5.9 Importance Sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
5.10 Sampling Importance Resampling . . . . . . . . . . . . . . . . . . . . . . . . . 91
5.11 Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
5.12 Summary of R Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
5.13 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
6 Markov Chain Monte Carlo Methods . . . . . . . . . . . . . . . . . . . . . . 101
6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
6.2 Introduction to Discrete Markov Chains . . . . . . . . . . . . . . . . . . . . 101
6.3 Metropolis-Hasting Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
6.4 Gibbs Sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
6.5 MCMC Output Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
6.6 A Strategy in Bayesian Computing . . . . . . . . . . . . . . . . . . . . . . . . 108
6.7 Learning About a Normal Population from Grouped Data . . . . 108
6.8 Example of Output Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
6.9 Modeling Data with Cauchy Errors . . . . . . . . . . . . . . . . . . . . . . . . 116
Contents ix
6.10 Analysis of the Stanford Heart Transplant Data . . . . . . . . . . . . . 124
6.11 Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
6.12 Summary of R Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
6.13 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
7 Hierarchical Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
7.2 Introduction to Hierarchical Modeling . . . . . . . . . . . . . . . . . . . . . . 137
7.3 Individual and Combined Estimates . . . . . . . . . . . . . . . . . . . . . . . 139
7.4 Equal Mortality Rates? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
7.5 Modeling a Prior Belief of Exchangeability . . . . . . . . . . . . . . . . . . 145
7.6 Posterior Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
7.7 Simulating from the Posterior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
7.8 Posterior Inferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
7.8.1 Shrinkage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
7.8.2 Comparing Hospitals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
7.9 Posterior Predictive Model Checking . . . . . . . . . . . . . . . . . . . . . . . 155
7.10 Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
7.11 Summary of R Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
7.12 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
8 Model Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
8.2 Comparison of Hypotheses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
8.3 A One-Sided Test of a Normal Mean . . . . . . . . . . . . . . . . . . . . . . . 164
8.4 A Two-Sided Test of a Normal Mean . . . . . . . . . . . . . . . . . . . . . . 167
8.5 Comparing Two Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
8.6 Models for Soccer Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
8.7 Is a Baseball Hitter Really Streaky? . . . . . . . . . . . . . . . . . . . . . . . 172
8.8 A Test of Independence in a Two-Way Contingency Table . . . . 176
8.9 Further Reading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
8.10 Summary of R Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
8.11 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
9 Regression Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
9.2 Normal Linear Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
9.2.1 The Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
9.2.2 The Posterior Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . 188
9.2.3 Prediction of Future Observations . . . . . . . . . . . . . . . . . . . 188
9.2.4 Computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
9.2.5 Model Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
9.2.6 An Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
9.3 Survival Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
9.4 Further Reading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
x Contents
9.5 Summary of R Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
9.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
10 Gibbs Sampling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
10.2 Robust Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
10.3 Binary Response Regression with a Probit Link . . . . . . . . . . . . . 216
10.4 Estimating a Table of Means . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
10.4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
10.4.2 A Flat Prior Over the Restricted Space . . . . . . . . . . . . . . 223
10.4.3 A Hierarchical Regression Prior . . . . . . . . . . . . . . . . . . . . . 227
10.4.4 Predicting the Success of Future Students . . . . . . . . . . . . 232
10.5 Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
10.6 Summary of R Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
10.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
11 Using R to Interface with WinBUGS . . . . . . . . . . . . . . . . . . . . . . 237
11.1 Introduction to WinBUGS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
11.2 An R Interface to WinBUGS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
11.3 MCMC Diagnostics Using the boa Package . . . . . . . . . . . . . . . . . 239
11.4 A Change-Point Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
11.5 A Robust Regression Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
11.6 Estimating Career Trajectories . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
11.7 Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
11.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263

下载地址
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------