Chapter 3
One-Parameter Models
One-parameter models provide the cleanest laboratory for mastering the mechanics of Bayesian inference: sufficient statistics, conjugate updating by kernel recognition, posterior predictive distributions, credible intervals, and the unifying theory of exponential families.Peter D. Hoff. A First Course in Bayesian Statistical Methods. Springer Texts in Statistics. Springer, New York, 2009. ISBN 978-0-387-92299-7. doi: 10.1007/978-0-387-92407-6
3.1The Binomial–Beta Model#
Let , where is a population proportion (for instance, the fraction of women aged 65+ in the 1998 GSS reporting general happiness: , ). The joint sampling probability is
(3.1)By the Fisher–Neyman factorization theorem, a statistic is a sufficient statistic for if and only if the sampling density factors as where does not depend on . In (3.1), and the likelihood depends on only through ; consequently, for any prior , the posterior is identical whether we condition on the full sequence or only on the sufficient count .
3.1.1Beta Conjugacy and Kernel Recognition#
Definition 3.1 (Conjugate Prior Family). A class of prior distributions for is conjugate for a sampling model ifHoward Raiffa and Robert Schlaifer. Applied Statistical Decision Theory. Harvard Business School, Boston, 1961
Suppose , with density
on (the uniform prior on is the special case ). Multiplying prior and binomial likelihood and dropping factors independent of gives
(3.2)Because (3.2) has the exact functional form (kernel) of a density and both densities must integrate to , they are identically equal—no integration required! This kernel recognition trick is used in every chapter of Hoff.
Proposition 3.2 (Beta–Binomial Update and Prediction). If and with , set and . Then:
Posterior: , with mean
(3.3)Posterior predictive (single trial): because a future draw is conditionally independent of given (),
(3.4)Posterior predictive ( future trials): the total count follows a beta–binomial distribution:
(3.5)where .
Notice the intuitive pseudo-count interpretation: acts as prior successes, as prior failures, and as the prior sample size. Notice also that is not marginally independent of : the observed data inform , which in turn shifts our prediction for .
3.2Credible Regions: Coverage, Quantiles, and HPD#
After observing , how do we summarize plausible values of with an interval ? Hoff emphasizes the sharp distinction between post-experimental and pre-experimental probability:
Definition 3.3 (Bayesian vs. Frequentist Coverage).
- An interval has Bayesian coverage (a credible interval) if .
- A random interval has frequentist coverage if, before observing , for all .
Under regular continuous models, Welch and PeersB. L. Welch and H. W. Peers. On Formulae for Confidence Points Based on Integrals of Weighted Likelihoods. Journal of the Royal Statistical Society, Series B, 25(2):318–329, 1963 and HartiganJohn A. Hartigan. Note on the Confidence-Prior of Welch and Peers. Journal of the Royal Statistical Society, Series B, 28:55–56, 1966 showed that two-sided Bayesian credible intervals also achieve frequentist coverage asymptotically (for discrete binomial data, lattice effects introduce oscillations unless intervals are randomizedLawrence D. Brown, T. Tony Cai, and Anirban DasGupta. Interval Estimation for a Binomial Proportion. Statistical Science, 16(2):101–133, 2001). Thus Bayesian intervals inherit strong long-run coverage while retaining a direct post-data probability interpretation.
There are two standard ways to construct a Bayesian region:
- Equal-tailed quantile interval: , putting posterior probability in each tail. Easy to compute from quantiles or Monte Carlo draws, and invariant under strictly monotone reparameterizations: if is strictly increasing, the quantile interval for is simply .
- Highest Posterior Density (HPD) region: a subset with such that every point inside has higher posterior density than every point outside: .
An HPD region is the shortest possible region of a given probability content, and for multimodal posteriors it naturally splits into disjoint intervals. However, unlike quantile intervals, HPD regions are not invariant under nonlinear reparameterizations because the Jacobian reshapes the density height! For (from under a uniform prior), the 95% equal-tailed quantile interval is (width ), whereas the 95% HPD interval is (width , at density threshold ; Figure 3.1).Note a typographical slip in the 2009 printing of Hoff (p. 43), which writes [0.04, 0.048] instead of [0.04, 0.48] for the 95% HPD of ; see Appendix C.
3.3The Poisson–Gamma Model#
For count data with , note the mean–variance equality . The likelihood is proportional to , so is again sufficient, and the conjugate prior is the gamma distribution (shape , rate ):
(3.6)Multiplying prior and likelihood yields the conjugate posterior and the exact negative binomial posterior predictive distribution:
Proposition 3.4 (Poisson–Gamma Update and Predictive Variance). Let and , with and . Then:
Posterior: , with
Here acts as prior sample size and as prior total count.
Posterior predictive: integrating out gives a distribution,
(3.7)with mean and variance
(3.8)
Proof. For the posterior,
which is the kernel of . For the predictive distribution, using and the gamma integral :
which rearranges immediately into (3.7). The predictive variance (3.8) follows directly from the law of total variance:
□
Equation (3.8) captures a universal law of Bayesian prediction: predictive variance equals expected sampling variance plus variance from parameter uncertainty. As , , but irreducible sampling variability remains.
3.3.1Crucial Distinction: Population Means vs. Individuals#
In Hoff’s GSS birth-rate analysis ( for women aged 40 without a bachelor’s degree; with a degree; common prior ), the posteriors are and . Comparing the population means gives —strong evidence that the average rates differ. Yet comparing two randomly drawn women yields and (Figure 3.1). Strong evidence of a difference in population means does not imply that the difference is large relative to individual variability.
3.4Exponential Families and Diaconis–Ylvisaker Priors#
Both the binomial and Poisson models are instances of a one-parameter exponential family:
(3.9)where is the natural parameter and is the sufficient statistic. Diaconis and YlvisakerPersi Diaconis and Donald Ylvisaker. Conjugate Priors for Exponential Families. The Annals of Statistics, 7(2):269–281, 1979 proved that the canonical conjugate prior takes the form
(3.10)which is proper whenever and lies in the interior of the convex hull of the support of . Under i.i.d. observations with sample average , it updates linearly to , and satisfies : thus is the prior expectation of the mean sufficient statistic and is the equivalent prior sample size.
To translate (3.10) from the natural parameter back to the standard parameter , we apply the change-of-variables Jacobian :
Binary: , so and , giving
i.e. .
Poisson: , so and , giving , i.e. .
| Model | Natural | Conjugate prior on | Weakly informative () | ||
|---|---|---|---|---|---|
| ; at , Jeffreys’ | |||||
import numpy as np
from scipy import stats
# Poisson-Gamma birth rates: exact posterior summaries & Negative Binomial predictive
a, b = 2, 1
n1, sy1 = 111, 217
n2, sy2 = 44, 66
# Note: scipy.stats.gamma uses scale = 1/rate
ci1 = stats.gamma.ppf([0.025, 0.975], a=a + sy1, scale=1 / (b + n1))
ci2 = stats.gamma.ppf([0.025, 0.975], a=a + sy2, scale=1 / (b + n2))
print("No degree 95% CI:", np.round(ci1, 3))
print("Degree 95% CI:", np.round(ci2, 3))
# Posterior predictive PMF: scipy.stats.nbinom(n=a_n, p=b_n/(b_n+1))
y_vals = np.arange(0, 6)
pmf1 = stats.nbinom.pmf(y_vals, a + sy1, (b + n1) / (b + n1 + 1))
print("Pred PMF (no degree, y=0..5):", np.round(pmf1, 3))3.5Modern Developments: Misspecification and Calibrated Prediction#
3.5.1Generalized and Coarsened Posteriors#
A generalized posterior replaces the log-likelihood by a chosen loss, and a coarsened posterior tempers the likelihood to allow for a model that is only approximately right.Beyond Hoff (2009). This material is not in Hoff’s book; it follows Bissiri, Holmes, and Walker and Miller and Dunson, and it modernizes the conjugate updates of this chapter for misspecified models.P. G. Bissiri, C. C. Holmes, and S. G. Walker. A General Framework for Updating Belief Distributions. Journal of the Royal Statistical Society Series B: Statistical Methodology, 78(5):1103–1130, 2016. doi: 10.1111/rssb.12158; and Jeffrey W. Miller and David B. Dunson. Robust Bayesian Inference via Coarsening. Journal of the American Statistical Association, 114(527):1113–1125, 2019. doi: 10.1080/01621459.2018.1469995 For a loss and learning rate ,
(3.11)Why it holds: (3.11) is the distribution that minimizes , because that objective equals plus a constant. The choice , is Bayes’ rule. Coarsening conditions on the data being close in relative entropy to a sample from the model, with an exponential prior of rate on the distance; approximately, this gives the log-likelihood loss with . The Diaconis–Ylvisaker prior (3.10) then updates with in place of :
(3.12)The effective sample size saturates at , so the posterior width does not vanish. For the GSS data (, , uniform prior), gives and moves the posterior mean and standard deviation from and to and .
When to use it. Use it when is large and small model errors would otherwise yield spurious certainty, or when only a loss is available. If the model is trusted, the ordinary update is sharper; or must be chosen and reported.
3.5.2Conformal Bayes#
Conformal Bayes uses a posterior predictive such as (3.7) to rank observations, and draws its coverage from exchangeability rather than from the model.Beyond Hoff (2009). This material is not in Hoff’s book; it follows Fong and Holmes and Hoff’s own later paper. Conformal prediction itself predates 2009, as does the use of Bayesian predictive scores within it; the add-one-in computation and Hoff’s Bayes-optimal formulation come from these later papers.Edwin Fong and Chris C. Holmes. Conformal Bayesian Computation. In Advances in Neural Information Processing Systems, volume 34, pages 18268–18279, 2021; and Peter Hoff. Bayes-optimal prediction with frequentist coverage control. Bernoulli, 29(2):901–928, 2023. doi: 10.3150/22-BEJ1484 For a candidate value of , put , let be the predictive density of observation given the augmented sample, and define
(3.13)Why it holds: the augmented posterior is symmetric in the observations, so if are exchangeable (Definition 2.4) then so are the scores. Hence , and for every , even if the sampling model is wrong. No refitting is required: draws with weights proportional to (“add-one-in” importance sampling) target the augmented posterior. In the Poisson–gamma model even this is unnecessary, since is the probability of .
Hoff’s version starts from the opposite end: among prediction regions with guaranteed frequentist coverage, it seeks the one with the smallest expected volume under the Bayesian model. The prior then buys precision, not validity.
When to use it. Use it when prediction intervals must be calibrated in repeated use and the sampling model is doubtful. The guarantee is marginal over the sample and the new observation, not conditional on the realized . Since data that are i.i.d. given are exchangeable, it holds at every fixed : it is a predictive analogue, with , of the frequentist coverage in Definition 3.3. With a credible model, the predictive (3.7) alone is simpler and gives full probabilities.
3.5.3Computational & Symbolic Check#
The Python block reproduces the coarsened GSS posterior of (3.12) and evaluates the conformal set (3.13) for the illustrative counts under a prior, so that and .Beyond Hoff (2009). This computational check and its Wolfram symbolic counterpart below verify the modern methods in this section and are not in Hoff’s book.
import numpy as np
from scipy import stats
n, y, alpha = 129, 118, 50 # coarsened GSS posterior, uniform prior
for zeta in (1.0, alpha / (alpha + n)):
post = stats.beta(1 + zeta * y, 1 + zeta * (n - y))
print(f"ESS={zeta*n:.2f}: mean={post.mean():.4f}, sd={post.std():.4f}")
for m in (10**3, 10**5, 10**7):
print(f"n={m}: ESS={alpha*m/(alpha+m):.3f} -> {alpha}")
data, a, b = np.array([0, 1, 2, 2, 6]), 2, 2 # conformal Bayes, Poisson-gamma
an, bn = a + data.sum(), b + len(data)
def conf_p(yc):
aug = np.append(data, yc)
sig = stats.nbinom.pmf(aug, an + yc, (bn + 1) / (bn + 2))
return np.mean(sig <= sig[-1])
p = [conf_p(k) for k in range(9)]
print(np.round(p, 3), "80% set:", [k for k in range(9) if p[k] > 0.2])// Chapter 3 (modern): coarsened beta posterior & conformal negative-binomial score
const ess = await show`al*n/(al + n)`await show`Limit[${ess}, n -> Infinity, Assumptions -> al > 0]`await show`N[Table[With[{a = 1 + z*118, b = 1 + z*11},
{129*z, a/(a + b), Sqrt[a*b/((a + b)^2*(a + b + 1))]}], {z, {1, 50/179}}]]`const sig = await show`(bn + 1)^(an + y)*(bn + 2)^(-an - y - yi)*Gamma[an + y + yi] / (yi! * Gamma[an + y])`await show`Assuming[an > 0 && bn > 0 && y >= 0 && yi >= 0 && Element[{y, yi}, Integers], FullSimplify[
Integrate[th^yi*Exp[-th]/yi! * (bn + 1)^(an + y)/Gamma[an + y]*th^(an + y - 1)*Exp[-(bn + 1)*th],
{th, 0, Infinity}] / (${sig})]]`await show`Table[With[{s = Table[(${sig}) /. {an -> 13, bn -> 7, y -> yc, yi -> v}, {v, {0, 1, 2, 2, 6, yc}}]},
Count[s, v_ /; v <= Last[s]]/6], {yc, 0, 8}]`3.6Symbolic Check in Wolfram Language#
Integrates out of the Poisson–Gamma posterior symbolically in wolfram-ws-bridge JavaScript mode to recover the Negative Binomial predictive PMF, mean, and variance, derives the general symbolic Beta interval mass , and then instantiates both on the GSS fertility counts and the 95% HPD interval.
// Chapter 3: Symbolic Poisson-Gamma predictive & general Beta(a,b) HPD integral
const { Times, Divide, Power, Exp, Minus, Subtract, Gamma, Factorial, th, yt, an, bn } = W
const pois = Divide(Times(Power(th, yt), Exp(Minus(th))), Factorial(yt))
const gam = Times(Divide(Power(bn, an), Gamma(an)), Power(th, Subtract(an, 1)), Exp(Times(-1, bn, th)))
const pred = await show`Assuming[an > 0 && bn > 0 && yt >= 0 && Element[yt, Integers],
FullSimplify[Integrate[${pois} * ${gam}, {th, 0, Infinity}]]]`const predMean = await show`Assuming[an > 0 && bn > 0, FullSimplify[Sum[yt * ${pred}, {yt, 0, Infinity}]]]`await show`Assuming[an > 0 && bn > 0,
FullSimplify[Sum[yt^2 * ${pred}, {yt, 0, Infinity}] - (${predMean})^2]]`// Symbolic interval probability Int_l^u Beta(a, b) for general HPD system
const betaMass = await show`Assuming[a > 0 && b > 0 && 0 < l < u < 1,
FullSimplify[Integrate[t^(a - 1)*(1 - t)^(b - 1) / Beta[a, b], {t, l, u}]]]`// Instantiate GSS no-degree group (an = 219, bn = 112) and Beta(3, 9) 95% HPD
await show`N[Table[${pred} /. {an -> 219, bn -> 112}, {yt, 0, 5}]]`await show`{l, u, u - l} /. FindRoot[{
l^(a - 1)*(1 - l)^(b - 1) == u^(a - 1)*(1 - u)^(b - 1),
(${betaMass}) == 95/100} /. {a -> 3, b -> 9}, {{l, 0.04}, {u, 0.48}}]`3.7Exercises#
Exercise 3.5. Let and define the log-odds . Compute both the equal-tailed 95% credible interval and the 95% HPD interval for , and compare them against the log-odds transform of the -intervals and . Verify that the quantile interval transforms identically while the HPD interval does not.
Symbolic Solution & Instantiation
Derive the exact log-odds density of via the logistic Jacobian.// Ex 3.1: Log-odds HPD non-invariance vs. quantile monotone invariance for Beta(3, 9)
const pg = await show`FullSimplify[(E^(a*g)*(1 + E^g)^(-a - b)) / Beta[a, b]]`await show`{g /. FindRoot[Integrate[${pg} /. {a -> 3, b -> 9}, {g, -Infinity, g}] == 25/1000, {g, -2.7}],
g /. FindRoot[Integrate[${pg} /. {a -> 3, b -> 9}, {g, -Infinity, g}] == 975/1000, {g, 0.1}]}`await show`{gl, gu} /. FindRoot[{
(${pg} /. {a -> 3, b -> 9, g -> gl}) == (${pg} /. {a -> 3, b -> 9, g -> gu}),
Integrate[${pg} /. {a -> 3, b -> 9}, {g, gl, gu}] == 95/100}, {{gl, -2.9}, {gu, 0.0}}]`await show`N[{Log[0.0406/(1 - 0.0406)], Log[0.4837/(1 - 0.4837)]}]`Exercise 3.6. Using the law of total variance, derive the exact mean and variance of the beta–binomial posterior predictive count in (3.5), and show that its variance exceeds the binomial variance by a factor .
Symbolic Solution & Instantiation
Write the posterior mean of .// Ex 3.2: Beta-Binomial posterior predictive mean, variance & overdispersion factor
const meanT = await show`an / (an + bn)`const varT = await show`(an*bn) / ((an + bn)^2*(an + bn + 1))`const meanS = await show`Factor[m * ${meanT}]`const varS = await show`Factor[m*((${meanT})*(1 - ${meanT}) - ${varT}) + m^2*(${varT})]`const ratio = await show`Factor[${varS} / (m*(${meanT})*(1 - ${meanT}))]`await show`N[{${meanS}, ${ratio}} /. {an -> 2, bn -> 40, m -> 20}]`Exercise 3.7. Cast the exponential sampling model () into the exponential-family form (3.9), write down its Diaconis–Ylvisaker conjugate prior (3.10), and confirm that the conjugate family is .
Symbolic Solution & Instantiation
Write the Diaconis–Ylvisaker conjugate prior kernel in the natural parameter of the exponential model.// Ex 3.3: Exponential model (h=1, c=-phi, t=y) -> Diaconis-Ylvisaker prior -> Gamma(n0 + 1, n0*t0)
const dyPhi = await show`(-phi)^n0 * Exp[n0 * t0 * phi]`await show`FullSimplify[(${dyPhi} /. phi -> -th) * Abs[D[-th, th]], th > 0]`await show`{n0 + 1, n0*t0, (n0 + 1)/(n0*t0)} /. {n0 -> 2, t0 -> 3}`