Overview

11 Bayesian hypothesis testing: Asking the right questions when hypothesizing

The chapter introduces Bayesian hypothesis testing as a more direct way to compare competing explanations of data than classical p-values. Using a website redesign example, it contrasts the frequentist approach, which asks how surprising the observed conversions would be if the baseline rate were true, with the Bayesian approach, which explicitly compares a null model against an alternative model. Instead of focusing only on whether data are unusual under one hypothesis, Bayesian testing evaluates which hypothesis makes the data more plausible and uses that comparison to support real decisions.

A central tool in this framework is the Bayes factor, defined as the ratio of the data likelihoods under two competing hypotheses. In the example, the Bayes factor compares a fixed conversion rate of 0.1 with a broader beta model over possible rates. The chapter shows how this value can favor one model, how it differs from a p-value, and why the Bayesian setup requires a clear specification of both hypotheses. It also emphasizes that marginal likelihoods can be computed directly in simple cases, though more complex models may require approximation.

Beyond testing, the chapter highlights why Bayesian reasoning is especially useful in practice: it accounts for prior beliefs, lets evidence accumulate over time, and supports decision-making through posterior distributions rather than binary accept-or-reject rules. A small p-value or low likelihood under one hypothesis does not by itself settle the question, because prior plausibility and alternative explanations matter too. By updating beliefs as new data arrive, Bayesian methods can combine results across replications and estimate quantities like the probability that a conversion rate exceeds a business threshold. The chapter closes by showing how these posterior beliefs can be paired with costs and benefits to choose actions based on expected utility, rather than on statistical significance alone.

The PMF of the binomial distribution representing the number of conversions out of 500 site visitors given the null hypothesis. Most probability mass centers around 50 conversions.
The PMF of the binomial distribution representing the number of conversions out of 500 site visitors given the null hypothesis. Most probability mass centers around 50 conversions.
The right tail region of the distribution corresponds to the event that the outcome is at least as extreme as the data. The likelihood of this event gives the 𝑝-value of the hypothesis test.
The right tail region of the distribution corresponds to the event that the outcome is at least as extreme as the data. The likelihood of this event gives the 𝑝-value of the hypothesis test.
Two competing hypotheses about the conversion rate 𝑟. The first hypothesis states that 𝑟 is equal to 0.1, while the second states that 𝑟 follows a Beta(1, 1) distribution.
Two competing hypotheses about the conversion rate 𝑟. The first hypothesis states that 𝑟 is equal to 0.1, while the second states that 𝑟 follows a Beta(1, 1) distribution.
Diagram of Bayesian reasoning in weighing prior probabilities against evidence likelihoods to produce posteriors. The final posterior probabilities are what should inform court decisions.
Diagram of Bayesian reasoning in weighing prior probabilities against evidence likelihoods to produce posteriors. The final posterior probabilities are what should inform court decisions.
Comparisons between the results from Bayesian hypothesis testing with the Bayes factor under a uniform prior (left) and a more informative prior (right). With the more informative prior, the Bayes factor offers support for both hypotheses, thus leading to less conclusive results about conversion improvement.
Comparisons between the results from Bayesian hypothesis testing with the Bayes factor under a uniform prior (left) and a more informative prior (right). With the more informative prior, the Bayes factor offers support for both hypotheses, thus leading to less conclusive results about conversion improvement.
Left: the 𝑝-values obtained from independent binomial tests throughout six studies, only one of which shows statistical significance (in the frequentist sense). Right: the evolution of the Bayes factor comparing the constant hypothesis and a beta distribution that continually updates in light of new data. We gradually observe more evidence in support of the beta model.
Left: the 𝑝-values obtained from independent binomial tests throughout six studies, only one of which shows statistical significance (in the frequentist sense). Right: the evolution of the Bayes factor comparing the constant hypothesis and a beta distribution that continually updates in light of new data. We gradually observe more evidence in support of the beta model.

Summary

  • Classical hypothesis testing evaluates how surprising the data are under a null hypothesis using a 𝑝-value.
  • A 𝑝-value doesn’t tell us how likely a hypothesis is given the data, nor does it directly guide decision making.
  • Bayesian hypothesis testing treats hypotheses as competing models and compares how well they explain the observed data.
  • The Bayes factor measures the relative evidence for two hypotheses by comparing their marginal likelihoods.
  • Unlike 𝑝-values, Bayes factors allow us to quantify evidence in favor of either hypothesis, rather than only rejecting one hypothesis.
  • Bayesian methods require explicitly specifying both competing hypotheses, making assumptions more transparent.
  • Incorporating prior knowledge can meaningfully affect conclusions, especially when data are limited.
  • Bayesian evidence accumulates naturally over time, allowing for sequential analysis over multiple replicated experiments without starting from scratch.
  • Misinterpreting conditional probabilities (such as confusing 𝑝(𝐻 | 𝐷) with 𝑝(𝐷 | 𝐻)) can lead to serious reasoning errors, as illustrated by the prosecutor’s paradox.
  • Posterior distributions can provide richer information than hypothesis tests, enabling us to answer more targeted questions about outcomes.
  • Decisions should be based not only on evidence, but also on consequences, which can be formalized using expected values of possible actions.

FAQ

What is the main difference between frequentist and Bayesian hypothesis testing?Frequentist testing starts with a null hypothesis, asks how surprising the observed data would be if it were true, and uses a p-value to decide whether to reject it. Bayesian testing compares competing hypotheses directly and measures how strongly the data support one model over another, often using the Bayes factor.
What does a p-value actually tell us?A p-value tells us the probability of observing data at least as extreme as the observed result, assuming the null hypothesis is true. It does not tell us the probability that the null hypothesis itself is true.
Why is the p-value not enough for decision-making?A p-value only tells us how unusual the data are under the null hypothesis. It does not directly tell us which action to take, such as whether to launch a new website design or what the probability is that the new design is better.
What is the Bayes factor?The Bayes factor is the ratio of the likelihood of the data under one hypothesis to the likelihood of the data under another hypothesis. It tells us how much more likely the observed data are under one model compared to the other.
How do we interpret a Bayes factor greater than 1?If the Bayes factor is greater than 1, the data favor the first hypothesis. For example, a Bayes factor of about 4.68 means the first model explains the data almost five times as well as the second model.
Why does Bayesian hypothesis testing require explicit alternative models?Bayesian testing requires us to specify exactly what the alternative hypothesis predicts, usually as a probability distribution. This is useful because it makes the competing explanations clear and allows us to compare them directly with the data.
How does prior knowledge affect Bayesian hypothesis testing?Bayesian testing can incorporate prior beliefs or domain knowledge through the prior distribution. If prior knowledge suggests only a small improvement is plausible, a more informative prior can change the Bayes factor and lead to a different conclusion.
Why is Bayesian hypothesis testing better for accumulating evidence over time?Bayesian methods update beliefs as new data arrive, so evidence accumulates continuously. This means you can keep checking results without breaking the inference the way repeated peeking can in frequentist testing.
What is the prosecutor’s paradox, and how does Bayesian reasoning help?The prosecutor’s paradox is the mistake of confusing the probability of observing evidence given innocence with the probability of innocence given the evidence. Bayesian reasoning corrects this by combining prior probabilities with the likelihood of the evidence under competing hypotheses.
How can Bayesian methods go beyond hypothesis testing?Bayesian methods can be used to answer decision-oriented questions, such as the probability that a conversion rate is above a useful threshold or whether launching a product is worth the risk. They do this by using the posterior distribution and expected utility, not just a binary reject-or-not decision.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking Bayes Grokking Bayes ebook for free
Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking Bayes Grokking Bayes ebook for free