Roever 2020 - Marginal Likelihood and Conditional Posteriors

Summary

With a uniform or normal prior on , integrating out of the NNHM likelihood is Gaussian and gives a closed-form marginal likelihood for , and the conditional posterior is exactly normal with the familiar inverse-variance mean and SD . The marginal posterior of is then one-dimensional, so the joint posterior factors as and the effect’s marginal is a continuous normal mixture. This is the core of the whole package.

Overview

The same quantities and are the frequentist fixed-effect () and random-effects () estimate and standard error, which is the bridge to Roever 2020 - Posterior Predictive Checks and Frequentist Connection.

Main Content

Marginal likelihood, uniform effect prior

Marginal likelihood of (Eq. 15-18, derivation Eq. 32-44)

For ,

where, with ,

Log form (Eq. 18):

Derivation (Appendix A.3)

Expand the exponent as a quadratic in : with , , . Complete the square: with , and

The remaining Gaussian integral over equals , and , giving the stated result.

Conjugate normal effect prior

Marginal likelihood with (Eq. 19-22)

The prior parameters enter like an extra data point :

As it reduces to the uniform-prior case (Eq. 17-18).

Conditional posterior of the effect (Sec. 2.5)

For a uniform or normal effect prior, . is the conditional maximum likelihood estimate and its conditional standard error: gives the fixed-effect estimate, a random-effects estimate (Hedges and Olkin 1985, Sec. 6).

Marginal and joint posterior

Factorisation and normal-mixture marginal (Eq. 23-26)

The prior independence is what makes this work. The normalising constant of is a one-dimensional integral for any if the posterior is proper. The effect’s marginal is a continuous mixture of normals (Seidel 2010; Lindsay 1995). Grid points and weights come from the DIRECT algorithm (Roever 2020 - DIRECT Algorithm Implementation and Calibration).

Examples

Posterior for and on a grid

The complete worked example (six studies) is in Roever 2020 - Pediatric Liver Transplant Worked Example. Core code:

import numpy as np
from scipy import stats
def posterior_grid(y, sigma, mu_prior=(0.0, 4.0), tau_scale=0.5, tmax=4.0, n=40001):
    mup, sp = mu_prior; tg = np.linspace(0, tmax, n)
    def cond(t):                                   # mu_hat(tau), sigma_hat(tau), Eq. 21
        P = 1/sp**2 + (1/(sigma**2+t**2)).sum()
        return (mup/sp**2 + (y/(sigma**2+t**2)).sum())/P, P**-.5
    def logml(t):                                  # Eq. 22 via p(y|m,t) p(m) / p(m|y,t) at m = mu_hat
        m, s = cond(t)
        return stats.norm.logpdf(y, m, np.sqrt(sigma**2+t**2)).sum() + stats.norm.logpdf(m, mup, sp) - stats.norm.logpdf(m, m, s)
    lp = np.array([logml(t) for t in tg]) + stats.halfnorm.logpdf(tg, scale=tau_scale)
    p = np.exp(lp-lp.max()); p /= np.trapezoid(p, tg)      # p(tau | y)
    ms = np.array([cond(t) for t in tg])                    # conditional normals p(mu | tau, y)
    return tg, p, ms                                        # mu-marginal = sum_j N(ms[j]) * p[j] * dtau

Connections

  • Hierarchical Models: the “conditional posterior given the hyperparameter, then average over the hyperparameter posterior” pattern is the standard hierarchical-model decomposition (Gelman et al. 2014 Sec. 5.4).
  • The frequentist Knapp-Hartung/HKSJ method (IntHout 2014 - HKSJ and DerSimonian-Laird Formal Specification) can be read as an approximate way of widening for the uncertainty that this note integrates over exactly.

See Also