Bayes action for two hypotheses
Proposition taught in Bayesian hypotheses and model comparison, part of Bayesian statistics
Bayes action for two hypotheses

| Type | Proposition |
| Taught in | Bayesian hypotheses and model comparison |
| Part | Bayesian statistics |
| Worked examples | 1 |
These probabilities do not by themselves define an action. If choosing action a_0 when H_1 is true costs L_{01} and choosing a_1 when H_0 is true costs L_{10}, the posterior expected losses are
\rho(a_0\mid x)=L_{01}\mathbb{P}(H_1\mid x), \qquad \rho(a_1\mid x)=L_{10}\mathbb{P}(H_0\mid x).
Choose a_0 when \begin{align*} L_{01}\mathbb{P}(H_1\mid x) &<L_{10}\mathbb{P}(H_0\mid x)\\ \Longleftrightarrow\quad \frac{\mathbb{P}(H_0\mid x)}{\mathbb{P}(H_1\mid x)} &>\frac{L_{01}}{L_{10}}. \end{align*} Equal losses reduce the threshold to one. This separates the probability calculation from the decision rule.
Examples
Imperfect-fruit decision
Worked example from Bayesian hypotheses and model comparison
Let X_i be the number of imperfect pieces in box i, with about 100 pieces per box. “Imperfect” must be defined before the data are collected so that producer and analyst classify fruit in the same way. The model is
X_i\mid\theta\stackrel{\mathrm{iid}}{\sim}\operatorname{Poisson}(\theta), \qquad H_0:\theta\leq10, \quad H_1:\theta>10.
For the observed sample, n=20 and S=\sum_i x_i=177; the stated prior is \theta\sim\operatorname{Gamma}(12,1) in shape–rate form.
Question. Find the posterior distribution, the posterior probabilities and odds for H_0 and H_1, and an equal-tailed 95\% credible interval. Explain why the interval may cross 10 even when most posterior mass lies below it.
Solution. Because the posterior for \theta is continuous,
\mathbb{P}(\theta=10\mid{\boldsymbol{x}})=0.
Consequently it makes no numerical difference whether equality is assigned to H_0 or H_1. This is a statement about the continuous parameter, even though the observed fruit counts are discrete.
For n boxes and S=\sum_i x_i, the likelihood is \begin{aligned} p({\boldsymbol{x}}\mid\theta) &=\prod_{i=1}^n\frac{e^{-\theta}\theta^{x_i}}{x_i!}\\ &=\left(\prod_{i=1}^n\frac1{x_i!}\right) e^{-n\theta}\theta^{\sum_i x_i}\\ &\propto e^{-n\theta}\theta^S. \end{aligned} The working total is S=177 for n=20.
The stated prior is \theta\sim\operatorname{Gamma}(12,1) in the standard shape–rate convention, so
p(\theta)=\frac1{\Gamma(12)}\theta^{12-1}e^{-\theta} \propto\theta^{11}e^{-\theta}.
Multiplying by the likelihood gives \begin{align*} p(\theta\mid{\boldsymbol{x}}) &\propto \theta^S e^{-n\theta}\theta^{11}e^{-\theta}\\ &=\theta^{S+11}e^{-(n+1)\theta}\\ &=\theta^{189-1}e^{-21\theta}. \end{align*} Therefore the internally consistent shape–rate update is \boxed{\theta\mid{\boldsymbol{x}}\sim\operatorname{Gamma}(189,21)}. Its posterior mean is
\mathbb{E}(\theta\mid{\boldsymbol{x}})=\frac{189}{21}=9.
The MLE is S/n=177/20=8.85. Although the prior mean 12 lies above the boundary 10, the data move the posterior centre below it.
Let \gamma(a,z)=\int_0^zt^{a-1}e^{-t}\,\mathrm{d} t be the lower incomplete Gamma function. If T\sim\operatorname{Gamma}(a,b), then
\mathbb{P}(T\leq t)=\frac{\gamma(a,bt)}{\Gamma(a)}.
Consequently, \begin{align*} \mathbb{P}(H_0\mid{\boldsymbol{x}}) &=\mathbb{P}(\theta\leq10\mid{\boldsymbol{x}})\\ &=\frac{\gamma(189,21\cdot10)}{\Gamma(189)}\\ &=0.93298381,\\ \mathbb{P}(H_1\mid{\boldsymbol{x}})&=1-0.93298381=0.06701619. \end{align*} The posterior odds are
\frac{\mathbb{P}(H_0\mid{\boldsymbol{x}})}{\mathbb{P}(H_1\mid{\boldsymbol{x}})} =\frac{0.93298381}{0.06701619} \approx13.92.
The equal-tailed 95\% credible interval is approximately (7.76,10.33). It crosses 10, while 93.3\% of posterior mass lies at or below 10. These are different summaries: interval inclusion does not produce a general accept/reject rule for an interval hypothesis.
A convention check uses the other Gamma convention. Writing a prior kernel p(\theta)\propto\theta^\alpha e^{-\beta\theta} with \alpha=12 describes \operatorname{Gamma}(13,1), not the stated \operatorname{Gamma}(12,1). That alternative gives \theta\mid x\sim\operatorname{Gamma}(190,21), posterior mean 190/21\approx9.05, \mathbb{P}(\theta\leq10\mid x)=0.92320087, odds 12.02, and interval (7.81,10.38). The main calculation above follows the stated shape–rate prior; the alternative is retained here so that neither that result nor the convention error is hidden.
Used in
- Taught in Bayesian hypotheses and model comparison, where the derivation and examples are.
- All 15 questions on Bayesian hypotheses and model comparison
See also
Posterior hypothesis probability · Posterior-odds factorisation · Marginal likelihood and Bayes factor · A hypothesis region is not a separate model