24小时热门版块排行榜    

查看: 296  |  回复: 1
当前主题已经存档。

likeac

至尊木虫 (职业作家)


[资源] 【转贴】R语言贝叶斯计算(Bayesian Computation with R)

与大家分享,谢谢!
http://www.namipan.com/d/Bayesia ... 3a4c2e988d25e424b00

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 FurtherReading......................................... 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 UsingaDiscretePrior ................................... 20
2.4 UsingaBetaPrior ...................................... 22
2.5 Using a Histogram Prior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.6 Prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.7 FurtherReading......................................... 34
2.8 Summary of R Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.9 Exercises ............................................... 35

3 Single-Parameter Models .................................. 39
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.2 Normal Distribution with Known Mean
butUnknownVariance................................... 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 FurtherReading......................................... 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 ABioassayExperiment .................................. 60
4.5 Comparing Two Proportions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
4.6 FurtherReading......................................... 70
4.7 Summary of R Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.8 Exercises ............................................... 71
5 Introduction to Bayesian Computation .................... 75
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.2 ComputingIntegrals ..................................... 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 TheExample ........................................... 82
5.7 Monte Carlo Method for Computing Integrals . . . . . . . . . . . . . . . 84
5.8 Rejection Sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
5.9 ImportanceSampling .................................... 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 GibbsSampling .........................................106
6.5 MCMCOutputAnalysis .................................106
6.6 A Strategy in Bayesian Computing . . . . . . . . . . . . . . . . . . . . . . . . 108
6.7 Learning About a Normal Population from Grouped Data . . . . 108
6.8 ExampleofOutputAnalysis ..............................113
6.9 Modeling Data with Cauchy Errors . . . . . . . . . . . . . . . . . . . . . . . . 116
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 PosteriorPredictiveModelChecking.......................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 ATwo-SidedTestofaNormalMean ......................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 FurtherReading.........................................180
8.10 Summary of R Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
8.11 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
9 Regression Models .........................................187
9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
9.2 NormalLinearRegression ................................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 SurvivalModeling .......................................199
9.4 FurtherReading.........................................204
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

[ Last edited by laizuliang on 2008-11-19 at 19:59 ]
回复此楼

» 猜你喜欢

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

yinjj

金虫 (职业作家)


good book! 五星级评价。
2楼2008-10-26 13:26:01
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 likeac 的主题更新
☆ 无星级 ★ 一星级 ★★★ 三星级 ★★★★★ 五星级
普通表情 高级回复 (可上传附件)
信息提示
请填处理意见