Lecture 29 Credible Intervals and Bayesian Testing
Lecture 28 introduced the posterior distribution as the complete Bayesian answer. In this lecture we answer the interval question of lecture 26 and the testing question of lectures 22 to 25 in posterior terms, and then set the two approaches side by side on the mean of a normal sample; lecture 30 shows a comparison of this kind in R.
We use the two conjugate pairs from lecture 28. The first is the Beta posterior for the Bernoulli model from example 28.5. The second is the normal posterior from proposition 28.6: for a sample from the normal distribution with known variance and prior , the posterior distribution is with
We consider the data set from example 26.3: observations with and . Assume that before the data were collected we expected the mean to be around and we chose the prior . Then the posterior precision is and the posterior mean is , i.e. the posterior distribution is .
29.1 Credible Intervals
A confidence interval, as given in definition 26.1, is a random interval which covers the fixed parameter with a given probability. In contrast, in a Bayesian model the data are fixed after observation, the parameter is random and an interval estimate is a set which contains most of the posterior probability.
Let be the posterior density of given the data and let . An interval is a credible interval for with credibility , if
The equal-tailed credible interval is the interval , between the - and -quantiles of the posterior distribution.
The probability in the definition is a probability about , for the given data set: the sentence “ is in with probability ” (which we had to forbid in lecture 26) is the statement that a credible interval makes. The trade-off is that this probability depends on the prior distribution.
Any interval with posterior probability is a credible interval. The equal-tailed interval is the usual choice, because the endpoints of this interval are quantiles. The alternative is to find the shortest set with this probability.
A highest posterior density (HPD) set with credibility is the set
where is chosen such that .
The set is the shortest set with posterior probability , since replacing part of it by a region where the density is below requires more length for the same probability. For a unimodal posterior distribution, is an interval, called the HPD interval. If the density is continuous, it takes the value at each endpoint which is not on the boundary of . For a symmetric, unimodal posterior distribution, the HPD interval is the equal-tailed interval (exercise 29.1).
If the posterior distribution is equal to the normal distribution , then the density is symmetric around and decreases as it gets further away from this point. Thus, the HPD interval is the equal-tailed interval
For our data set and the prior we have , and the credible interval is , i.e. the interval . The credible interval is shifted towards the prior mean and is shorter than the confidence interval from example 26.3, because the prior provides additional information. In the case of the flat prior from section 28.4, the posterior distribution is and the credible interval (29.2) coincides with the confidence interval . The reason for this coincidence is explained in section 29.3.
29.2 Bayesian Testing
In the Bayesian model a hypothesis , in the sense of definition 22.1, is an event concerning the random variable and thus has a probability before and after the data are seen. Testing does not require new theory.
Let and be hypotheses with positive prior probability. Then the posterior probability of is given by
Similarly, we can find the posterior probability of . A Bayesian test rejects if falls below a given threshold. If both hypotheses are treated equally, the test instead chooses the hypothesis with the higher posterior probability.
The threshold plays the role of the level of definition 22.6, but the two numbers are not comparable: bounds the probability of a type I error over repeated samples, whereas the threshold bounds the posterior probability that a rejection is wrong, for the data in hand. Any asymmetry between the hypotheses can be expressed by the prior.
For our data set we test against . With the prior the posterior distribution is , and thus we have
and consequently . A symmetric decision between the hypotheses favours , but the rule with threshold does not reject . For the flat prior the hypotheses have no prior probabilities, but the formal posterior still gives
Here the evidence against is much weaker than for the prior : this prior, which has only of its mass below , contributed substantially to the result above.
The same approach can be used for a hypothesis about a proportion. For the posterior in example 28.5, the posterior probability of is the value of the Beta distribution function at . To find this value by hand, we approximate the posterior by the normal distribution with the same mean and variance. From table A.2 we find the mean and the variance , so that the standard deviation is . This gives
which is close to the exact value . Exercise 29.3 shows a case where the integral can be computed exactly.
A simple hypothesis has probability zero under every prior with a density, and thus for two simple hypotheses the prior must be a two-point distribution. The posterior is then a two-point distribution as well.
Let and be simple hypotheses and let the prior have probability for and for . Then the prior odds of against are and the posterior odds are .
By Bayes’ theorem (proposition A.20) we have
where . When we divide the two expressions, the term cancels and we find
i.e. the posterior odds are the prior odds times the likelihood ratio. In this context, the likelihood ratio is also called the Bayes factor in favour of . This is the inverse of the ratio considered in the Neyman–Pearson lemma, theorem 23.2. From the posterior odds we can derive the posterior probabilities as .
We use our data set again, this time to test against . Since the likelihood of a normal sample satisfies by exercise 28.3, the Bayes factor is
Here we have , and , so that the exponent is and the Bayes factor is . Since is closer to than to , the data favour by a factor of approximately two. If the prior odds are , the posterior odds are and . Exercise 29.4 treats a case where the prior odds are different from .
29.3 Comparing Frequentist and Bayesian Answers
Now we have two different sets of answers, for the same data, for the normal mean. We conclude by comparing the two sets.
The first difference is in the nature of the statements. A confidence interval is a statement about a procedure: it says that for repeated samples, the interval covers the fixed truth in of cases. A credible interval is a statement about the parameter, given the data and the prior. Similarly, a -value is computed assuming is true, whereas is the probability of the hypothesis given the data.
The second observation is that for the normal mean with known variance and a flat prior, the numerical answers coincide. Example 29.3 shows the two intervals coinciding, and the tests coincide as well: for the flat-prior posterior probability equals, by the symmetry of , the -value of the one-sided -test from example 22.7. As for the size in lecture 22, the supremum in definition 22.9 for the composite null hypothesis is attained at . For our data set both values equal .
The answers coincide because, as a function of , the flat-prior posterior density has the same shape as the density of as a function of . This is the reason why the misreadings in lectures 22 and 26 were so tempting: each of the two forbidden sentences, about the -value and about the confidence interval, is a true sentence about the flat-prior posterior for the simplest model.
The coincidence only holds for special models and priors. An informative prior, i.e. a proper prior which expresses knowledge about , moves the Bayesian answer towards the prior mean and makes the interval shorter, as in the case of above. If is close to the prior mean, this is an advantage, but if is far from the prior mean, the interval is moved away from the true value. The frequentist guarantee from definition 26.1 holds for all . A credible interval has no such guarantee: exercise 29.5 shows that its frequentist coverage can be far below when is far from the prior mean.
As the sample size increases, the influence of the prior decreases. For the normal mean, equation (29.1) shows that the weight of the prior mean in goes to zero and that as , so that for large the posterior is approximately , the posterior for the flat prior. The same effect holds for all regular models. The general version of this result, the Bernstein–von Mises theorem, is the Bayesian analogue of theorem 17.1: under the regularity conditions from definition 16.1, and for any prior density which is continuous and positive at the true value, the posterior distribution is approximately
where is the maximum likelihood estimator. We state this result without proof. The idea is that the log-posterior is up to a constant, and that the log-likelihood grows like while does not. From (29.4) we know that the equal-tailed credible interval is approximately the Wald interval of proposition 26.8, independently of the prior: for large sample size both approaches give approximately the same interval, with frequentist coverage approximately .
-
•
A credible interval with credibility has posterior probability : this is a probability statement about for the given data, taking the prior into account. The equal-tailed interval is based on posterior quantiles, the HPD interval is the shortest one, and for symmetric, unimodal posteriors both intervals coincide.
-
•
For the normal mean with known variance and normal prior, the credible interval is ; for the flat prior this interval coincides with the confidence interval .
-
•
A Bayesian test compares posterior probabilities of the hypotheses, or rejects if falls below a threshold. For two simple hypotheses, the posterior odds are the prior odds times the likelihood ratio, known as the Bayes factor.
-
•
The level of a test and the confidence level of an interval are statements about the procedure applied to repeated samples, whereas the credibility of an interval is a statement about the parameter given one data set. For the normal mean with known variance and flat prior, the intervals, and the one-sided test and -value, agree numerically while the statements do not have the same meaning.
-
•
An informative prior shifts the Bayesian answer towards the prior mean and shortens the interval. For large the posterior is approximately and the credible and Wald intervals approximately coincide.
Let the posterior density be continuous, strictly increasing on and strictly decreasing on .
-
1.
Show that the HPD set from definition 29.2 is an interval with and .
-
2.
Assume that the density is symmetric about , i.e. that for all . Show that the HPD interval with credibility coincides with the equal-tailed interval .
-
3.
Now assume that the posterior density is continuous and strictly decreasing on and zero elsewhere. Show that the HPD set with credibility is the one-sided interval and that this interval is shorter than the equal-tailed interval.
In example 28.5, a Bernoulli sample with and successes was combined with the prior to obtain the posterior distribution with mean . The quantiles of a Beta distribution have to be found numerically. The - and -quantiles of are and .
-
1.
Write down the equal-tailed credible interval for and compare the mid-point of this interval to the posterior mean.
-
2.
Show that the posterior density has its maximum at , so that the mode of the posterior distribution is above the mean.
-
3.
The HPD interval for , found numerically, is . Using definition 29.2, explain why this interval is shifted towards the mode, compared to the equal-tailed interval. Also explain why the difference between the two intervals decreases as increases.
Assume that we have observed two successes in three Bernoulli trials with success probability , and the prior distribution of is flat on the interval .
-
1.
Determine the posterior distribution of .
-
2.
Calculate the posterior probability of by integrating the posterior density. Also, calculate the posterior odds of against .
-
3.
The prior odds of against were . By what factor have the data changed these odds?
-
4.
Write down the equations for the boundaries of the equal-tailed credible interval and explain why these equations are best solved numerically.
In the situation of example 22.7, a sample of size from has mean . We want to compare the simple hypotheses and .
-
1.
Compute the Bayes factor in favour of .
-
2.
Before the data were available, was three times as likely as . Compute the posterior odds and the posterior probability of .
-
3.
The one-sided -test from lecture 22 gives the -value for these data. Compare this -value with your posterior probability of and explain why the two numbers can differ so much, although both count against .
-
4.
What value must the prior odds in favour of have for the posterior probability of to be greater than one half?
Let be i.i.d. with where is known, and let the prior be . Let be the weight of the prior mean in . Consider the credible interval (29.2) to be a random interval, as introduced in lecture 26, where is fixed and the data are random.
-
1.
Show that and that under the posterior mean satisfies .
-
2.
Determine the coverage probability as a function of .
-
3.
For , , , and , determine the coverage probability for and for and discuss the result as .
-
4.
Is the credible interval a confidence interval with level in the sense of definition 26.1? What happens to the coverage probability as with fixed?