4
Monte Carlo approximation
In the last chapter we saw examples in which a conjugate prior distribution for
an unknown parameter
θ
led to a posterior distribution for which there were
simple formulae for posterior means and variances. However, often we will
want to summarize other aspects of a posterior distribution. For example, we
may want to calculate Pr(
θ
∈
A

y
1
,...,y
n
) for arbitrary sets
A
. Alternatively,
we may be interested in means and standard deviations of some function of
θ
,
or the predictive distribution of missing or unobserved data. When comparing
two or more populations we may be interested in the posterior distribution
of

θ
1

θ
2

,
θ
1
/θ
2
, or max
{
θ
1
,...,θ
m
}
, all of which are functions of more
than one parameter. Obtaining exact values for these posterior quantities can
be diﬃcult or impossible, but if we can generate random sample values of
the parameters from their posterior distributions, then all of these posterior
quantities of interest can be approximated to an arbitrary degree of precision
using the Monte Carlo method.
4.1 The Monte Carlo method
In the last chapter we obtained the following posterior distributions for
birthrates of women without and with bachelor’s degrees, respectively:
p
(
θ
1

111
X
i
=1
Y
i,
1
= 217) = dgamma(
θ
1
,
219
,
112)
p
(
θ
2

44
X
i
=1
Y
i,
2
= 66) = dgamma(
θ
2
,
68
,
45)
Additionally, we modeled
θ
1
and
θ
2
as conditionally independent given the
data. It was claimed that Pr(
θ
1
> θ
2

∑
Y
i,
1
= 217
,
∑
Y
i,
2
= 66) = 0
.
97. How
was this probability calculated? From Chapter 2, we have
P.D. Hoﬀ,
A First Course in Bayesian Statistical Methods
,
Springer Texts in Statistics, DOI 10.1007/9780387924076
4,
c
±
Springer Science+Business Media, LLC 2009