Tutorials › Competing Risks and Multi-State Models › Sandwich Variance From Individual Score Processes

Counting Processes and Martingale Theory · Tutorial 466 of 699

Sandwich Variance From Individual Score Processes

Learn to aggregate individual score processes and calculate sandwich standard errors while distinguishing empirical score variation from model-based information.

Advanced 11 min read

What You'll Learn

  • Define a subject-level score contribution from counting-process martingales.
  • Construct the empirical score-variation matrix from independent subjects or clusters.
  • Derive the sandwich covariance estimator using score linearization.
  • Compare empirical score variation with predictable, model-based information.
  • Calculate scalar and multivariate sandwich variances in event-history examples.
  • Recognize when aggregation, independence, or information assumptions are not justified.

Why the Individual Score Matters

An event-history model can assign a score contribution to each observed subject or independent cluster. The total score is the sum of these contributions, but its variance depends on how scores vary between independent units. This distinction matters when a subject contributes repeated events or several event types: the subject’s entire history must first be combined into one score vector. Treating that history as several independent records can discard dependence and produce an incorrect variance.

The sandwich estimator combines two quantities. The bread measures how quickly the estimating score changes with the parameter. The meat measures empirical variation in the independent units’ scores. The resulting covariance estimate is useful alongside model-based information, which describes score variation implied by the specified intensity model.

Individual Martingale Scores and the Sandwich Formula

Suppose \(n\) independent subjects are followed over a specified observation interval. For subject \(i\), let \(N_{ik}(t)\) count events of type \(k\), and let \(Y_{ik}(t)\) indicate whether that event type is at risk. Under a multiplicative intensity model with parameter vector \(\beta\), the intensity is \(Y_{ik}(t)\lambda_{ik}(t;\beta)\). Define the compensated counting process \(M_{ik}(t)=N_{ik}(t)-\int_0^t Y_{ik}(u)\lambda_{ik}(u;\beta)\,du\), and the log-intensity derivative \(S_{ik}(t;\beta)=\partial\log\lambda_{ik}(t;\beta)/\partial\beta\).

Definition: The individual score process contribution is the parameter-dimension column vector $$ U_i(\beta)=\sum_k\int_0^\tau S_{ik}(t;\beta)\,dM_{ik}(t). $$ The total score is \(U(\beta)=\sum_{i=1}^n U_i(\beta)\). At an interior maximum-likelihood estimate \(\hat\beta\), the total score is zero, or is numerically close to zero.

This representation presumes the specified intensity is the conditional event rate given the observed past, the covariate and risk processes used in the intensity are predictable, and the compensator is well defined. The martingale score has mean zero under the model when the relevant integrability conditions hold. The subjects’ complete observed histories are the independent units; repeated events within a subject do not create new independent units.

Define the normalized sensitivity, or bread, by \(A(\beta)=-n^{-1}\partial U(\beta)/\partial\beta^\mathsf{T}\), and let \(\hat A=A(\hat\beta)\). Define the empirical score-variation matrix, or meat, by \(\hat B=n^{-1}\sum_i U_i(\hat\beta)U_i(\hat\beta)^\mathsf{T}\). The sandwich covariance estimator is

$$ \widehat{\operatorname{Var}}(\hat\beta) =\frac{1}{n}\hat A^{-1}\hat B(\hat A^{-1})^\mathsf{T}. $$

The transpose on the final bread is essential when the sensitivity matrix is not symmetric. Equivalently, if \(H=-\partial U(\hat\beta)/\partial\beta^\mathsf{T}=n\hat A\) and \(J=\sum_i U_i(\hat\beta)U_i(\hat\beta)^\mathsf{T}=n\hat B\), the same estimator is \(H^{-1}J(H^{-1})^\mathsf{T}\). The two expressions differ only in whether the factors of \(n\) are included in the bread and meat.

Why the Sandwich Has This Form

Assume independent subjects, a consistent interior estimator, differentiable scores, a nonsingular limiting sensitivity, finite score second moments, and a central limit theorem for the summed scores. Also assume the fitted estimating equation is the sum of the subject scores. A first-order expansion around the true parameter \(\beta_0\) gives

$$ 0=U(\hat\beta) \approx U(\beta_0)-nA(\beta_0)(\hat\beta-\beta_0). $$

Rearranging and multiplying by \(\sqrt n\) yields \(\sqrt n(\hat\beta-\beta_0)\approx A(\beta_0)^{-1}n^{-1/2}\sum_i U_i(\beta_0)\). If the individual scores have covariance matrix \(B\), independence gives covariance \(B\) for their normalized sum. Thus the limiting covariance of \(\sqrt n(\hat\beta-\beta_0)\) is \(A^{-1}B(A^{-1})^\mathsf{T}\); the covariance of \(\hat\beta\) is this matrix divided by \(n\). Replacing the unknown sensitivity and score covariance by their sample estimates gives the sandwich estimator.

This derivation explains why the meat must be formed from independent-unit scores. It also shows the assumptions are substantive: a singular or poorly estimated bread makes the result unstable, and dependence between supposed independent units invalidates the simple sum of outer products.

Model-Based Information Versus Empirical Score Variation

The model-based alternative uses the information implied by the intensity model. In the common case where distinct event types have no simultaneous jumps, the predictable variation of the individual martingale score is

$$ \langle U_i\rangle(\tau) =\sum_k\int_0^\tau S_{ik}(t;\beta)S_{ik}(t;\beta)^\mathsf{T} Y_{ik}(t)\lambda_{ik}(t;\beta)\,dt. $$

The corresponding normalized model-based information is the sum of these predictable variation matrices divided by \(n\). Under the correctly specified likelihood and the usual regularity conditions, expected score variation agrees with expected information. This is the information identity. The empirical meat instead uses the outer products of the realized, whole-subject scores. With a large sample under the information identity, both approaches target the same asymptotic covariance. In a finite sample, their numerical estimates need not agree.

If event types can jump together, the predictable variation must include the relevant cross-variation terms; simply adding separate type-specific terms is not generally sufficient. The score outer product automatically retains cross-component variation within each subject. Model-based information can be more stable in small samples, while the empirical meat directly estimates variation across independent units. Neither calculation excuses a wrong independence structure or an ill-conditioned bread.

Worked Example: A Scalar Sandwich Estimate

Suppose four independent hypothetical subjects have fitted score contributions \(0.8,-0.4,0.2,-0.6\) for a scalar parameter. Their total score is zero, as required at the fitted value. Suppose the normalized sensitivity is \(\hat A=1.5\). Treat the scores as independent subject-level contributions from a correctly specified intensity model with finite second moments; assume the fitted score equation and sensitivity calculation are valid.

The empirical meat is the average squared score:

$$ \hat B=\frac{0.8^2+(-0.4)^2+0.2^2+(-0.6)^2}{4} =\frac{0.64+0.16+0.04+0.36}{4}=0.30. $$

For \(n=4\), the sandwich variance estimate and standard error are

$$ \widehat{\operatorname{Var}}(\hat\beta) =\frac{1}{4}\frac{0.30}{1.5^2} =\frac{0.30}{9}=0.03333, \qquad \widehat{SE}(\hat\beta)=\sqrt{0.03333}=0.1826. $$

If the model-based information estimate were \(\hat A=1.5\) per subject, its covariance estimate would be \(1/(4\times1.5)=0.1667\), not \(0.03333\). These are different finite-sample estimates from the two methods; this example alone does not determine why they differ. The parameter’s units determine the variance units, and the standard error has the parameter’s units.

Worked Example: Preserving Covariance Between Score Components

Consider four independent hypothetical subjects with two-component fitted scores \((1,2)^\mathsf{T},(-1,-2)^\mathsf{T},(2,1)^\mathsf{T},(-2,-1)^\mathsf{T}\). They sum to zero. Suppose the normalized sensitivity is \(\hat A=\begin{pmatrix}2&0\\0&1\end{pmatrix}\), which is nonsingular. The score components may, for example, correspond to two parameters estimated from the same event histories.

The empirical meat is the average of the four outer products:

$$ \hat B=\frac14 \left[ \begin{pmatrix}1&2\\2&4\end{pmatrix} +\begin{pmatrix}1&2\\2&4\end{pmatrix} +\begin{pmatrix}4&2\\2&1\end{pmatrix} +\begin{pmatrix}4&2\\2&1\end{pmatrix} \right] =\begin{pmatrix}2.5&2\\2&2.5\end{pmatrix}. $$

Since \(\hat A^{-1}=\begin{pmatrix}0.5&0\\0&1\end{pmatrix}\), the sandwich estimate for \(n=4\) is

$$ \widehat{\operatorname{Var}}(\hat\beta) =\frac14 \begin{pmatrix}0.5&0\\0&1\end{pmatrix} \begin{pmatrix}2.5&2\\2&2.5\end{pmatrix} \begin{pmatrix}0.5&0\\0&1\end{pmatrix} =\begin{pmatrix}0.15625&0.25\\0.25&0.625\end{pmatrix}. $$

The off-diagonal covariance is \(0.25\). It arises because the two score components are evaluated on the same subjects. Calculating separate scalar meats and setting their covariance to zero would fail to preserve this observed association.

Worked Example: A Right-Censored Exponential Event Model

For a hypothetical exponential event-time model with rate \(\lambda=\exp(\beta)\), the score for subject \(i\) is \(U_i(\beta)=\delta_i-\lambda T_i\), where \(T_i\) is observed time and \(\delta_i\) indicates an event. Assume independent subjects, no informative censoring, and a correctly specified constant-rate intensity. Two hypothetical subjects experience events at times 1 and 3 years. The fitted rate is \(\hat\lambda=2/(1+3)=0.5\) events per year, so \(\hat\beta=\log(0.5)\).

The scores are \(1-(0.5)(1)=0.5\) and \(1-(0.5)(3)=-0.5\), which sum to zero. The observed negative second derivative of the total log likelihood is the total number of events, 2, so the normalized sensitivity is \(\hat A=2/2=1\). The empirical meat is

$$ \hat B=\frac{0.5^2+(-0.5)^2}{2}=0.25. $$

Consequently, the sandwich variance estimate for the log-rate parameter is \(0.25/(2\times1^2)=0.125\), and its standard error is \(\sqrt{0.125}=0.3536\). The model-based information per subject is \(\hat A=1\), giving variance \(1/(2\times1)=0.5\) and standard error \(0.7071\). With only two subjects, the empirical score-variation estimate is especially variable. This calculation illustrates a finite-sample contrast; it does not show that one estimate must be preferred in every application.

Implementation Checks, Comparisons, and Limitations

1
Define the independent unit.
Use a subject or independent cluster, not each event, when repeated event histories within that unit are dependent.
2
Compute each complete score.
Evaluate \(U_i(\hat\beta)\) using that unit’s observed history and the fitted parameter.
3
Check the fitted equation and bread.
Confirm \(\sum_i U_i(\hat\beta)\) is close to zero and that the sensitivity is nonsingular and numerically stable.
4
Form and inspect the meat.
Sum the individual outer products, retain off-diagonal entries, and check that the resulting matrix is symmetric and positive semidefinite up to numerical rounding.
5
Compare with model-based information.
Compute it from the fitted intensity and its assumptions, then report which covariance estimator supports the inferential result.

A common error is to treat every event contributed by one subject as an independent score. That reasoning uses the wrong independent units and can omit within-subject covariance. The correction is to sum all of that subject’s score-process contributions first, then take one outer product of the resulting vector. Another error is to omit the \(1/n\) factor while using normalized bread and meat; the unnormalized formula \(H^{-1}J(H^{-1})^\mathsf{T}\) is equivalent, but mixing the two conventions is not.

The sandwich estimates uncertainty around the fitted parameter; it does not change the point estimate, repair a singular model, or establish that the intensity specification is appropriate. A few influential scores can dominate the meat, and a poorly conditioned bread can inflate or destabilize the covariance. These diagnostics should prompt examination of the data structure and model calculations, not automatic removal of influential subjects. For dependent clusters, the independent cluster—not the individual event—must be the unit used in the empirical meat, and enough independent clusters are needed for reliable large-sample inference.

The central comparison is therefore between empirical variation of whole-unit scores and information implied by the model. Under the stated regularity and information-identity conditions they agree asymptotically; in finite samples they can differ. Reporting the estimator, independent unit, and assumptions makes the variance calculation interpretable.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. For three independent subjects with scalar scores \(1,-0.5,-0.5\), calculate the empirical meat.
  2. With the scores in Question 1 and normalized sensitivity \(A=2\), calculate the sandwich variance estimate.
  3. Why must two score components from the same subject contribute jointly to the outer-product meat?
  4. State one condition under which the empirical score meat and model-based information agree asymptotically.

Solutions. (1) \(\hat B=(1^2+(-0.5)^2+(-0.5)^2)/3=(1+0.25+0.25)/3=0.5\). (2) For \(n=3\), the estimate is \((1/3)(0.5/2^2)=0.04167\). (3) Their joint outer product retains within-subject covariance; treating components or repeated events as independent can incorrectly set covariance terms to zero. (4) Under a correctly specified likelihood, the regularity conditions for the information identity, and independent units, expected score variation equals expected information; with consistent estimators, the empirical and model-based covariance estimates target the same asymptotic covariance.

Clinical Biostats