Simple Algorithm
Machine Learning · Convergence · 28 min

When the Model Is Wrong

Misspecified likelihoods, KL projections and sandwich errors.

Every model you fit is wrong: real noise is not exactly Gaussian, real counts are not exactly Poisson. Maximum likelihood still converges, but to the best approximation the model can offer, and its textbook standard errors can be badly off. This lesson finds that limit, repairs the uncertainty with the sandwich, and asks what a Bayesian posterior means when no parameter value is true.

What you’ll learn

  • Prove that under misspecification the MLE converges to the KL projection θ∗=arg min⁡θDKL(P ∥ Pθ)\boldsymbol\theta^* = \argmin_{\boldsymbol\theta}\KL(P \,\|\, P_{\boldsymbol\theta}), and compute it for common models.
  • Derive the sandwich covariance A−1BA−1A^{-1}BA^{-1}, compute robust standard errors, and explain what the information matrix equality says.
  • Explain quasi-likelihood and estimating equations, and when a wrong likelihood still estimates the right mean.
  • Describe how Bayesian posteriors behave under misspecification, why their credible sets lose coverage, and what generalized and tempered posteriors do about it.

What the MLE converges to

Box (1976) put the point bluntly: all models are wrong, so the scientist should ask what is importantly wrong rather than hope for a correct model. Make it precise. The data are i.i.d. from an unknown distribution PP, and the model {pθ}\{p_{\boldsymbol\theta}\} need not contain it (misspecification). The average log-likelihood still converges, 1nℓn(θ)→EP[log⁡pθ(x)]=−H(P)−DKL(P ∥ Pθ)\frac1n\ell_n(\boldsymbol\theta) \to \E_P[\log p_{\boldsymbol\theta}(x)] = -H(P) - \KL(P \,\|\, P_{\boldsymbol\theta}), so the natural target is the KL projection of PP onto the model:

θ∗=arg max⁡θ EP[log⁡pθ(x)]=arg min⁡θ DKL(P ∥ Pθ).\boldsymbol\theta^* = \argmax_{\boldsymbol\theta}\ \E_P\big[\log p_{\boldsymbol\theta}(x)\big] = \argmin_{\boldsymbol\theta}\ \KL(P \,\|\, P_{\boldsymbol\theta}).

The consistency proof is the one from Asymptotics of Maximum Likelihood with Eθ0\E_{\boldsymbol\theta_0} replaced by EP\E_P: uniform convergence plus a well-separated maximizer. What changes is the meaning of the limit. For an exponential family the projection is easy to find: differentiating EP[η⊤T(x)−A(η)]\E_P[\boldsymbol\eta^\top T(x) - A(\boldsymbol\eta)] gives ∇A(η∗)=EP[T(x)]\nabla A(\boldsymbol\eta^*) = \E_P[T(x)]. The KL projection onto an exponential family matches the true moments of TT, whatever PP is.

Model fittedTrue distributionWhat the MLE converges to
N(μ,σ2)\mathcal N(\mu, \sigma^2)any PP with finite variancethe true mean and variance: the moment-matched Gaussian
Poisson(λ)(\lambda)overdispersed countsλ∗=EP[x]\lambda^* = \E_P[x]: the right mean, the wrong variance
Exponential (rate λ\lambda)any positive PP with finite meanλ∗=1/EP[x]\lambda^* = 1/\E_P[x]
Linear regression, Gaussian noisenonlinear E[y∣x]\E[y \mid \mathbf x], any noisethe best linear predictor E[xx⊤]−1E[xy]\E[\mathbf x\mathbf x^\top]^{-1}\E[\mathbf xy]
Logistic regressionwrong link, omitted featuresthe w\mathbf w whose fitted probabilities are closest in KL to the true conditional distribution
Each limit is the best approximation in the model, measured by KL from the truth. Whether it answers your question is a separate matter: a Poisson rate is still the mean count, but the coefficient of a misspecified regression need not be the causal effect you wanted.

The sandwich

DerivationWhy the variance becomes A⁻¹BA⁻¹
  1. n (θ^n−θ∗)=[−1n∇2ℓn(θ~n)]−11n Un(θ∗),1n Un(θ∗)→dN(0,B)\sqrt n\,(\hat{\boldsymbol\theta}_n - \boldsymbol\theta^*) = \Big[-\tfrac1n\nabla^2\ell_n(\tilde{\boldsymbol\theta}_n)\Big]^{-1}\tfrac{1}{\sqrt n}\,U_n(\boldsymbol\theta^*),\qquad \tfrac{1}{\sqrt n}\,U_n(\boldsymbol\theta^*) \xrightarrow{d} \mathcal N(\mathbf 0, B)

    Linearize the score around θ∗\boldsymbol\theta^* exactly as in the correctly specified case. At the projection the expected score is still zero, EP[s(θ∗;x)]=∇θEP[log⁡pθ]∣θ∗=0\E_P[\mathbf s(\boldsymbol\theta^*; x)] = \nabla_{\boldsymbol\theta}\E_P[\log p_{\boldsymbol\theta}]\big|_{\boldsymbol\theta^*} = \mathbf 0, so the central limit theorem applies:

  2. n (θ^n−θ∗)→dN(0, A−1BA−1)\sqrt n\,(\hat{\boldsymbol\theta}_n - \boldsymbol\theta^*) \xrightarrow{d} \mathcal N\big(\mathbf 0,\ A^{-1}BA^{-1}\big)

    The bracket converges to the expected negative Hessian AA (the "bread"), and the score's covariance is BB (the "meat"):

  3. A^=−1n∑i=1n∇2log⁡pθ^(xi),B^=1n∑i=1ns(θ^;xi) s(θ^;xi)⊤,Cov⁡^(θ^)=1nA^−1B^A^−1\hat A = -\frac1n\sum_{i=1}^n \nabla^2\log p_{\hat{\boldsymbol\theta}}(x_i),\qquad \hat B = \frac1n\sum_{i=1}^n \mathbf s(\hat{\boldsymbol\theta}; x_i)\,\mathbf s(\hat{\boldsymbol\theta}; x_i)^\top,\qquad \widehat{\Cov}(\hat{\boldsymbol\theta}) = \frac1n\hat A^{-1}\hat B\hat A^{-1}

    If the model is correct, the two identities of the Fisher information give A=B=I(θ0)A = B = I(\boldsymbol\theta_0), the information matrix equality, and the sandwich collapses to I−1I^{-1}. Under misspecification nothing ties AA to BB. Both are estimated by plugging in the data:

A worked case. Fit a Poisson model to counts that really have mean μ\mu and variance σ2>μ\sigma^2 > \mu. The score is x/λ−1x/\lambda - 1 and the second derivative is −x/λ2-x/\lambda^2, so at λ∗=μ\lambda^* = \mu: A=1/μA = 1/\mu and B=Var⁡(x/μ)=σ2/μ2B = \Var(x/\mu) = \sigma^2/\mu^2. The sandwich is A−1BA−1=σ2A^{-1}BA^{-1} = \sigma^2, the true variance of xˉ\bar x times nn, while the model-based A−1=μA^{-1} = \mu assumes the variance equals the mean. With mean 4 and variance 12, model-based standard errors are too small by a factor 3≈1.73\sqrt 3 \approx 1.73, and every confidence interval built from them is too narrow.

These are the "Huber–White" or robust standard errors; for least squares they reduce to the heteroscedasticity-consistent estimators of Inference for Linear Models. Comparing A^\hat A with B^\hat B is itself a diagnostic: White (1982) turned it into the information matrix test of misspecification.

Estimating equations and quasi-likelihood

The sandwich never used the fact that s\mathbf s was a score. Any estimator defined by an estimating equation ∑iψ(xi,θ)=0\sum_i \boldsymbol\psi(x_i, \boldsymbol\theta) = \mathbf 0, an M-estimator, targets the root θ∗\boldsymbol\theta^* of EP[ψ(x,θ)]=0\E_P[\boldsymbol\psi(x, \boldsymbol\theta)] = \mathbf 0 and has asymptotic covariance A−1BA−⊤A^{-1}BA^{-\top} with A=−EP[∂ψ/∂θ]A = -\E_P[\partial\boldsymbol\psi/\partial\boldsymbol\theta] and B=EP[ψψ⊤]B = \E_P[\boldsymbol\psi\boldsymbol\psi^\top] (Huber, 1964, 1967). Maximum likelihood is the special case ψ=s\boldsymbol\psi = \mathbf s; the Huber loss of robust regression is another.

This frees you from specifying a full distribution. Quasi-likelihood (Wedderburn, 1974) assumes only a mean model μi(β)=E[yi∣xi]\mu_i(\boldsymbol\beta) = \E[y_i \mid \mathbf x_i] and a variance function, Var⁡[yi∣xi]=ϕ V(μi)\Var[y_i \mid \mathbf x_i] = \phi\,V(\mu_i), and solves

∑i=1n∂μi∂β yi−μi(β)V(μi)=0.\sum_{i=1}^n \frac{\partial\mu_i}{\partial\boldsymbol\beta}\,\frac{y_i - \mu_i(\boldsymbol\beta)}{V(\mu_i)} = \mathbf 0.

The equation has mean zero whenever the mean model is right, whatever the distribution and even if VV is wrong, so β^\hat{\boldsymbol\beta} is consistent for the true mean parameters. With V(μ)=μV(\mu) = \mu this is quasi-Poisson regression: the same coefficients as Poisson regression, with standard errors inflated by ϕ^\sqrt{\hat\phi}, where ϕ^\hat\phi is the Pearson χ2\chi^2 statistic divided by n−dn - d. Generalized estimating equations (Liang & Zeger, 1986) extend the idea to clustered and longitudinal data, with a working correlation inside clusters and sandwich standard errors that stay valid when that guess is wrong.

Check your understanding

You run Poisson regression with a log link on counts that are overdispersed: given x\mathbf x, the variance is about three times the mean, but the log-mean really is linear in x\mathbf x. What is true of the fit?

  1. The coefficients are inconsistent, so the model must be abandoned
  2. The coefficients are consistent for the true log-mean slopes, but the model-based standard errors are too small by about 3\sqrt 3
  3. Everything is fine: overdispersion only affects the intercept
  4. The coefficients and standard errors are both correct, because Poisson regression is a GLM
Show the answer

B. The coefficients are consistent for the true log-mean slopes, but the model-based standard errors are too small by about 3\sqrt 3

The Poisson score equations are the quasi-likelihood equations with V(μ)=μV(\mu) = \mu, which have mean zero whenever the mean model is right, so the coefficients are consistent. Their variance is the sandwich, about ϕ=3\phi = 3 times the model-based one. Quasi-Poisson or robust standard errors fix the inference; a negative binomial model may also fit better.

Bayes when the model is wrong

A Bayesian posterior under a misspecified likelihood still concentrates, around the same KL projection θ∗\boldsymbol\theta^* (Berk, 1966). The question is whether its width means anything.

Predict before you look

A Gaussian model for a mean assumes the noise variance is σ02\sigma_0^2, but the true variance is 4σ024\sigma_0^2. With a flat prior and lots of data, how often does the 95% credible interval for the mean actually contain the true mean?

Show the answer

67 %

The posterior is N(xˉ,σ02/n)\mathcal N(\bar x, \sigma_0^2/n), so the interval is xˉ±1.96 σ0/n\bar x \pm 1.96\,\sigma_0/\sqrt n, while xˉ\bar x really has standard deviation 2σ0/n2\sigma_0/\sqrt n. Coverage is Pr⁡(∣Z∣≤1.96/2)=Pr⁡(∣Z∣≤0.98)≈67%\Pr(\abs Z \le 1.96/2) = \Pr(\abs Z \le 0.98) \approx 67\%. Here A=1/σ02A = 1/\sigma_0^2 and B=4σ02/σ04=4/σ02B = 4\sigma_0^2/\sigma_0^4 = 4/\sigma_0^2: the posterior uses A−1A^{-1} where the sandwich would give 4σ024\sigma_0^2.

Several repairs reshape the posterior instead of discarding it:

  • Generalized Bayes (Bissiri, Holmes & Walker, 2016) updates beliefs about any loss-defined target with π(θ∣D)∝exp⁡(−η∑iL(θ,xi)) π(θ)\pi(\boldsymbol\theta \mid \data) \propto \exp\big(-\eta\sum_i L(\boldsymbol\theta, x_i)\big)\,\pi(\boldsymbol\theta), and shows that this is the coherent way to do so. Bayes' rule is the case L=−log⁡pθL = -\log p_{\boldsymbol\theta}, η=1\eta = 1.
  • Tempered (power) posteriors raise the likelihood to a learning rate η<1\eta < 1. Asymptotically the covariance becomes (ηnA)−1(\eta nA)^{-1}, so in one dimension η=A/B\eta = A/B restores calibrated intervals; in the example above η=1/4\eta = 1/4. In several dimensions a single scalar can fix the scale but not the shape, which motivates sandwich-adjusted posteriors (Müller, 2013).
  • Choosing η. SafeBayes (Grünwald & van Ommen, 2017) learns η\eta from the data after showing that ordinary Bayes can be inconsistent in a simple misspecified linear regression, placing mass on ever more complex models. Syring & Martin (2019) instead calibrate η\eta so that credible regions reach nominal coverage, and coarsened posteriors (Miller & Dunson, 2019) condition only on the data being close to the model, which behaves much like tempering.

Living with wrong models

Misspecification is not a reason to give up likelihoods, but to check them. Posterior predictive checks simulate replicated datasets from the fitted model and ask whether the real data look typical; a feature the model cannot reproduce is a feature it gets wrong (Gelman et al., 2013, chapter 6). Model expansion then adds what is missing: heavier tails (a Student-tt likelihood instead of a Gaussian), overdispersion (negative binomial instead of Poisson), or a mixture. And for prediction, comparing models by held-out predictive performance does not assume any of them is true (Bayesian Model Selection).

Key takeaways

  • Under misspecification the MLE converges to the KL projection θ∗=arg min⁡DKL(P ∥ Pθ)\boldsymbol\theta^* = \argmin\KL(P \,\|\, P_{\boldsymbol\theta}) (Huber; White). Onto an exponential family, the projection matches the true moments of TT; forward KL makes it mass-covering.
  • The asymptotic covariance becomes the sandwich A−1BA−1A^{-1}BA^{-1}, with AA the expected negative Hessian and BB the score covariance. They coincide when the model is right; when not, model-based standard errors can be far too small (a factor 3\sqrt 3 for Poisson counts with variance three times their mean).
  • Estimating equations need only a correct mean model: quasi-likelihood and GEE give consistent coefficients for the mean, with sandwich standard errors.
  • Misspecified posteriors concentrate at θ∗\boldsymbol\theta^* with covariance (nA)−1(nA)^{-1}, so credible sets can miscover. Generalized and tempered posteriors, with a learning rate chosen by SafeBayes or calibration, are the main repairs; posterior predictive checks find what needs fixing.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

You fit a Gaussian N(μ,σ2)\mathcal N(\mu, \sigma^2) by maximum likelihood to a large sample from a skewed distribution with mean 3 and variance 5. What do μ^\hat\mu and σ^2\hat\sigma^2 converge to?

  1. Nothing: the MLE is inconsistent when the model is wrong
  2. 33 and 55: the KL projection onto the Gaussians matches the mean and variance
  3. The mode and the squared interquartile range of the true distribution
  4. 33 and a value smaller than 55, because skewness lowers the fitted variance
Show the answer

B. 33 and 55: the KL projection onto the Gaussians matches the mean and variance

The Gaussians are an exponential family with T(x)=(x,x2)T(x) = (x, x^2), so the projection satisfies Eη∗[T]=EP[T]\E_{\boldsymbol\eta^*}[T] = \E_P[T]: the true mean and second moment, hence the true variance. The fit is "consistent", but for the moment-matched Gaussian, not for the skewed truth.

Question 2

When the model is correctly specified, what happens to the sandwich A−1BA−1A^{-1}BA^{-1}?

  1. It becomes I(θ0)−1I(\boldsymbol\theta_0)^{-1}, because A=B=I(θ0)A = B = I(\boldsymbol\theta_0)
  2. It becomes I(θ0)I(\boldsymbol\theta_0)
  3. It becomes zero, because there is no misspecification error
  4. It is undefined, because BB requires misspecification
Show the answer

A. It becomes I(θ0)−1I(\boldsymbol\theta_0)^{-1}, because A=B=I(θ0)A = B = I(\boldsymbol\theta_0)

The information matrix equality, E[ss⊤]=−E[∇2log⁡p]\E[\mathbf s\mathbf s^\top] = -\E[\nabla^2\log p], holds at the true parameter of a correct model, so A−1BA−1=I−1II−1=I−1A^{-1}BA^{-1} = I^{-1}II^{-1} = I^{-1}. Using the sandwich anyway costs little efficiency in large samples, which is why robust standard errors are a common default.

Question 3

A Bayesian analyst's likelihood is misspecified, and the data set is large. What does the posterior typically do?

  1. It fails to concentrate and stays as wide as the prior
  2. It is exactly calibrated, because Bayesian credible sets never depend on the model being right
  3. It concentrates on the true distribution, because the prior corrects the likelihood
  4. It concentrates near the KL projection θ∗\boldsymbol\theta^*, but its spread is governed by A−1A^{-1} instead of the sandwich, so credible sets can have the wrong coverage
Show the answer

D. It concentrates near the KL projection θ∗\boldsymbol\theta^*, but its spread is governed by A−1A^{-1} instead of the sandwich, so credible sets can have the wrong coverage

The posterior concentrates where the expected log-likelihood is highest, at θ∗\boldsymbol\theta^* (Berk, 1966), and is asymptotically N(θ^,(nA)−1)\mathcal N(\hat{\boldsymbol\theta}, (nA)^{-1}) (Kleijn & van der Vaart, 2012). The estimator's real variability is A−1BA−1/nA^{-1}BA^{-1}/n, so when A≠BA \ne B the intervals are too narrow or too wide.

Further reading

  • H. White, "Maximum likelihood estimation of misspecified models," Econometrica 50(1), 1–25 (1982).
  • P. J. Huber, "The behavior of maximum likelihood estimates under nonstandard conditions," Proceedings of the Fifth Berkeley Symposium on Mathematical Statistics and Probability, 221–233 (1967).
  • B. J. K. Kleijn & A. W. van der Vaart, "The Bernstein–von Mises theorem under misspecification," Electronic Journal of Statistics 6, 354–381 (2012).
  • P. G. Bissiri, C. C. Holmes & S. G. Walker, "A general framework for updating belief distributions," Journal of the Royal Statistical Society B 78(5), 1103–1130 (2016).
  • P. Grünwald & T. van Ommen, "Inconsistency of Bayesian inference for misspecified linear models, and a proposal for repairing it," Bayesian Analysis 12(4), 1069–1103 (2017).