Poisson imperfect-fruit example

Section of Bayesian hypotheses and model comparison, part of Bayesian statistics

Poisson imperfect-fruit example

Type Section
Taught in Bayesian hypotheses and model comparison
Part Bayesian statistics

Example 1 (Imperfect-fruit decision) 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.

Figure 1: The fruit posterior \operatorname{Gamma}(189,21), with the region \theta\leq10 shaded. The two summaries disagree in appearance only. The equal-tailed interval must leave 2.5\% in each tail, so its upper endpoint is pushed past 10; the shaded area answers a different question and puts 93.3\% of the mass at or below the boundary. Reading the crossing as a rejection substitutes one summary for the other.
Parameterisation check

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

See also

Posterior hypothesis probability · Bayes action for two hypotheses · Posterior-odds factorisation · Marginal likelihood and Bayes factor · A hypothesis region is not a separate model · Probability statements and decisions · Bayes factors and posterior odds · Bayes factor for independence in the 2×3 table

Glossary and index