![R Logo](rlogo_transp.gif)
Bayesian Statistics: An Introduction: R programs
Computer programs (in R) relating to the book
The R language is
available free.
Many of them make use of the HDR routines in the file
hdr.txt (improved on 10 January 2007 as
a result of comments by Jacob Colvin). A useful book for Bayesians
using the R language is J Albert,
Bayesian Computation with R, Springer-Verlag 2007;
see also the packages
LearnBayes,
R2WinBUGS,
boa and coda.
A useful A5 reference card for R is available here as
pdf or LaTeX source.
- Section 2.2 (rocks.txt - data on age of rocks)
- Section 2.3
(chests.txt - data on chest measurements)
- Section 2.7
(fig21.txt - program to draw Figure 2.1)
- Section 2.8
(ratweight.txt - data on uterine
weight of rats - mean assumed known)
- Section 2.12
(ratweight_unknownvar.txt -
data on uterine weight of rats - mean and variance both assumed unknown)
- Section 2.13 (wheat.txt - data on wheat
with a growth hormone)
- Section 3.1
(fig31.txt - program to draw Figure 3.1)
- Section 3.1 (limericks.txt - data on
limericks)
- Section 3.4
(misprints.txt - data on misprints
using reference prior)
- Section 3.5
(misprints_informative.txt
- data on misprints using informative prior)
- Section 3.6 (uniform.txt - data from a
uniform distribution)
- Section 3.8
(firstdigit.txt - data on the
first digit problem)
- Section 3.9
(accidents.txt - data illustrating
the circular normal distribution)
- Section 4.1
(w.txt - data about the W aprticle)
- Section 4.3
(ratweight.txt - data on uterine
weight of rats)
- Section 4.5
(pointnull.txt - point null hypotheses)
- Section 5.1
(ratdiet.txt - data about rat diet
with variances assumed known)
- Section 5.2
(ratdiet_equalvars.txt - data
about rat diet with variances assumed unknown but equal)
- Section 5.3
(ratdiet_unknownvars.txt -
data about rat diet with variances assumed unknown)
- Section 5.4
(hay.txt - data about hay yield)
- Section 5.5
(nitrogen.txt - data about nitrogen)
- Section 5.6
(inoculum.txt - Di Raimondo’s data on
bacterial inoculum on mice)
- Section 6.2
(cuckoo.txt - data on cuckoo eggs)
- Sections 6.3 and 6.4
(rain.txt - data on York rainfall)
- Sections 6.5
(scabindex.txt - data on scab index
for potatoes)
- Sections 7.3
(fish.txt - data on recapture of fish)
- Section 8.3 and Chapter 8, Exercise 4
(baseball.txt - baseball example)
- Section 8.4
(fig81.txt - program to draw Figure 8.1;
the same is also available in LaTeX)
- Sections 9.2
(semiconj.txt - semi-conjugate prior
with a normal likelihood for wheat yield data
- Sections 9.2
(blood.txt - hierachical normal model
for blood coagulation time)
- Sections 9.2 and 9.3
(dataaug.txt - genetic linkage example
on data augmentation)
- Section 9.4
(chained.txt - example on chained data
augmentation due to Casella and George)
- Section 9.4
(pumps.txt - example on pump failures)
- Sections 9.4
(blood.txt - semi-conjugate prior with
normal likelihood)
- Section 9.4
(fig93.txt - program to draw Figure 9.3)
- Section 9.4
(coal.txt - change point analysis of
coal disaster data)
- Section 9.5
(betasim.txt - simulation of beta
distribution by rejection sampling)
- Section 9.5
(reject.txt - example of rejection sampling)
- Section 9.5
(pumps2.txt - rejection sampling for pump
failures)
- Section 9.6
(bivarnorm.txt - simulation from a
bivariate normal distribution)
- Section 9.7
(pumpsmodel.txt - model file for
pumps data for use in R2OpenBUGS or R2OpenBUGS)
- Section 9.7
(pumps_r2winbugs.txt - pumps
data run via R2WinBUGS)
- Section 9.7
(pumps_r2openbugs.txt - pumps
data run via R2OpenBUGS)
- Section 9.7
(pumps_coda.txt - program segment for
use of coda)
- Section 9.8
(logistic.txt - example of logistic
regression)
- Chapter 9, Exercise 1
(integral.txt - crude Monte Carlo integration)
- Chapter 9, Exercise 3
(dataaug2.txt - genetic linkage
example from C A B Smith)
- Chapter 9, Exercise 5
(semicon2.txt - semi-conjugate prior
with normal likelihood)
- Chapter 9, Exercise 6
(hiernor2.txt - hierachical normal model)
- Chapter 9, Exercise 8
(dataaug2.txt - genetic linkage
example from C A B Smith)
- Chapter 9, Exercise 9
(chained.txt - example on chained data
augmentation due to Casella and George)
- Chapter 9, Exercise 10
(semicon2.txt - semi-conjugate prior
with normal likelihood)
- Chapter 9, Exercise 11
(rat data)
- rats.dat (data file)
- gelfand.pdf Extract from
Gelfand et. al. with a detailed description of the
hierarchical model for the rats data (LaTeX source at
gelfand.htm).
- wishart.txt (program to generate
random matrix with a Wishart distribution).
- rwishart.pdf
Extract (pp. 230-233) from W J Kennedy, Jr, and J E Gentle,
Statistical Computing, New York: Dekker 1980.
- Chapter 9, Exercise 12
(linkagemh.txt - genetic linkage
example using Metropolis-Hastings)
- Chapter 9, Exercise 14
(logistic.txt - bioassay data)
- Section 10.1
(naivemc.txt - naïve use of
Monte Carlo)
- Section 10.1
(conj_gamma.txt - the conjugate gamma
distribution and HDRs using Bayesian importance sampling)
- Section 10.2
(varbayes.txt - data on wheat yield
using variational Bayes)
- Section 10.4
(linkage_rej.txt - genetic linkage
example using ABC-REJ algorithm)
- Section 10.4
(linkage_mcmc.txt - genetic linkage
example using ABC-MCMC algorithm)
- Section 10.4
(linkage_prc.txt - genetic linkage
example using ABC-PRC algorithm)
- Chapter 10, Exercise 2
(sir_beta.txt - sampling importance
resampling for B(2,3))
- Chapter 10, Exercise 3
(sir_beta_hdr.txt - sampling importance
resampling for B(2,3) continued to find HDR)
- Chapter 10, Exercise 4
(varbayes.txt - methodology of Section 10.2
applied to dataset in Ex 16 on Chap 2)
- Chapter 10, Exercise 9
(linkage_rej_smith.txt - methodology
of Section 10.4 applid to dataset in Ex 3 on Chap 9)
- Appendix C
(hdr.txt - R programs for HDRs
and Behrens’ distribution)
Peter M. Lee
Revised 3 November 2013