From Observation-Level Scores to Matrices
A sandwich covariance estimate is only as transparent as its two ingredients. The bread records how the estimating equation changes when the regression coefficients change; the meat records the variability of the observation-level estimating contributions. For independent regression observations, both can be assembled from one contribution per observation.
Consider independent responses \(Y_1,\ldots,Y_n\), with fixed covariate vectors \(x_i\in\mathbb{R}^p\). Write \(\eta_i=x_i^\mathsf{T}\beta\), \(\mu_i=E[Y_i]\), and \(\mu_i=m(\eta_i)\), where \(m\) is differentiable. Suppose the specified variance function is \(V(\mu_i)>0\), and the variance model is \(\operatorname{Var}(Y_i)=\phi V(\mu_i)\), with fixed positive dispersion \(\phi\). Define \(h_i=d\mu_i/d\eta_i\). The quasi-score contribution for observation \(i\) is
The quasi-estimator \(\hat\beta\) solves \(U(\hat\beta)=0\). Use \(\hat\mu_i=m(x_i^\mathsf{T}\hat\beta)\), \(\hat h_i=m'(x_i^\mathsf{T}\hat\beta)\), and residual \(\hat r_i=Y_i-\hat\mu_i\) to evaluate the contributions at the fitted coefficients. The empirical meat is the sum of their outer products:
Thus the meat depends on the squared residuals, as well as the fitted mean through the score weight. Independence is what permits a sum of individual score outer products: there are no cross-observation covariance terms in the variance of \(U\).
Two Bread Matrices to Distinguish
The sensitivity bread is the negative derivative of the total score. Its empirical version is \(\hat A_{\mathrm{obs}}=-\partial U(\beta)/\partial\beta^\mathsf{T}\) evaluated at \(\hat\beta\). Differentiating the observation contribution gives
The residual term appears because the score weight can change with \(\beta\). Another common bread is the expected sensitivity, with the residual term removed:
This is the negative expected score derivative evaluated at the fitted means: under the specified mean model, \(E[Y_i-\mu_i]=0\), so the derivative term multiplied by the residual has expectation zero. The two breads need not be identical in a particular data set. State which is being used; the observed bread is the empirical derivative, whereas the expected bread is its variance-model-based counterpart.
Nonsingularity matters: if the fitted design and weights do not give a full-rank bread, its inverse does not exist and this sandwich formula cannot be used as written. Dispersion in these expressions is treated as fixed or plugged in; differentiating with respect to an estimated dispersion parameter would require a larger estimating system.
Why the Model-Based Meat Can Match the Bread
Proof. Because \(x_i\), \(\mu_i\), and \(h_i\) are fixed at a fixed \(\beta\), the score contribution is a fixed vector multiplier of \(Y_i-\mu_i\). Its expectation is
Independence and zero expectations imply that the covariance of the sum is the sum of the individual covariance matrices. For each observation,
Summing these matrices proves the stated covariance identity. The empirical meat replaces the unknown score second moments with the observed score outer products; the identity does not say those observed products equal their expectations in a finite sample. \(\square\)
This calculation explains how a variance assumption enters each component. It determines the score weight, and hence the bread, through \(V(\mu_i)\) and \(\phi\). It also determines the model-based score covariance. In contrast, the empirical meat uses the observed squared residuals rather than replacing them by their variance-model expectations.
Worked Calculations
Worked Example: Bernoulli Intercept With a Logit Link
Suppose four independent Bernoulli observations are \(1,0,1,0\), with an intercept-only logistic model and \(\phi=1\). The fitted probability is \(\hat\mu=\bar Y=2/4=1/2\). For the logit link, \(h=\mu(1-\mu)\), and for Bernoulli data \(V(\mu)=\mu(1-\mu)\). Thus \(h/V=1\).
Each score contribution is \(u_i=Y_i-\hat\mu\). The residuals are \(1/2,-1/2,1/2,-1/2\), and their sum is zero, confirming the intercept score equation. The expected bread is
The logit score weight \(h/V\) is constant, so the residual derivative term in the observed bread is zero; consequently \(\hat A_{\mathrm{obs}}=1\) as well. The empirical meat is
The scalar sandwich estimate is \(1^{-1}(1)1^{-1}=1\). In this example the observed meat happens to equal the bread; that equality is not guaranteed for other data sets.
Worked Example: Quasi-Poisson Intercept With Fixed Dispersion
Take independent counts \(1,2,3,4\), an intercept-only log-link model, and fixed \(\phi=2\), with \(V(\mu)=\mu\). The fitted mean is \(\hat\mu=\bar Y=10/4=2.5\). For a log link, \(h=\mu\), so \(h/(\phi V)=1/2\). The residuals are \(-1.5,-0.5,0.5,1.5\), which sum to zero; hence the fitted intercept solves the quasi-score equation.
The expected bread is
For a log link with the Poisson variance function, the score multiplier \(h/(\phi V)=1/\phi\) is constant in \(\eta\). Therefore the residual derivative term is zero and \(\hat A_{\mathrm{obs}}=5\). The empirical meat uses the observed squared residuals:
The resulting scalar sandwich estimate is \((1/5)(5/4)(1/5)=1/20=0.05\). If instead the meat were replaced by its model-based expectation, it would be \(5\), giving covariance estimate \(1/5=0.2\). These different numbers illustrate the distinction between an empirical meat and its variance-model expectation; the small observed sample need not reproduce that expectation.
Worked Example: A Fitted Poisson Regression With Two Coefficients
Let \(x_i=(1,i)^\mathsf{T}\) for \(i=0,1,2\), and observe counts \(Y=(5,2,5)\). Fit a Poisson log-link regression with \(\phi=1\). The fitted means \((4,4,4)\) are compatible with the model: \(\eta_i=\log 4+0\cdot i\), so \(\hat\beta=(\log 4,0)^\mathsf{T}\). The residuals are \((1,-2,1)\). The intercept score is \(1-2+1=0\), and the slope score is \(0(1)+1(-2)+2(1)=0\), so these are indeed fitted means satisfying both score equations.
For Poisson log-link regression, \(h_i=\mu_i\) and \(V(\mu_i)=\mu_i\), giving score weight \(h_i/V(\mu_i)=1\). The expected bread, which also equals the observed bread for this link and variance function, is
The empirical meat uses the residual squares \(1,4,1\):
The off-diagonal entry is \(0+4+2=6\); each outer product contributes to both symmetric off-diagonal entries. The inverse bread is
Multiplication gives
This example checks the full construction: the fitted means obey the regression structure and score equations, the meat is built from the correct outer products, and the final covariance uses the inverse bread on both sides.
Practical Checks and Common Mistakes
A useful way to avoid arithmetic and conceptual errors is to construct the matrices observation by observation. For each row, compute the fitted mean, residual, score multiplier, and outer product \(x_ix_i^\mathsf{T}\); then sum the weighted matrices. The following checks are especially valuable:
- Check the fitted model. For a log link, fitted means must have log means linear in the covariates. Also verify that the fitted residuals satisfy the score equations to numerical tolerance.
- Keep the score multiplier squared in the meat. The meat weight is \(\{h_i/[\phi V(\hat\mu_i)]\}^2\hat r_i^2\), not simply \(\hat r_i^2\) for every link and variance function.
- Use an outer product. A contribution is \(\hat r_i^2x_ix_i^\mathsf{T}\) times its scalar weight. The off-diagonal entries are not generally zero, and symmetry is a useful arithmetic check.
- Do not confuse expected and empirical meat. Replacing squared residuals by \(\phi V(\hat\mu_i)\) gives a model-based expectation, not the observed meat.
- Identify the bread being used. The observed derivative can contain a residual-dependent term. Removing it is justified for expected sensitivity, not as an algebraic identity for every fitted data set.
The bread and meat are therefore not decorative labels for two interchangeable weighted cross-products. The bread describes score sensitivity, and the meat describes score variation. Their separate construction makes clear which parts depend on the fitted regression, which parts use residual evidence, and which parts follow from the assumed mean–variance relationship.
Check Your Understanding
Use the observation-level score and the stated variance assumption to answer each question.
- For an independent regression observation, write the quasi-score contribution in terms of \(x_i\), \(h_i\), \(\phi\), \(V(\mu_i)\), and \(Y_i-\mu_i\).
- Explain why the empirical meat contains a squared residual and why independence permits summing individual score outer products.
- What term distinguishes the observed bread from the expected bread in the general differentiable-link expression?
- For a Poisson log-link model with \(\phi=1\), simplify the score multiplier \(h_i/V(\mu_i)\). What does this imply for the empirical meat?
- Why does replacing the empirical meat by the expected score covariance change the calculation, even when the variance model is correctly specified?