18.27 The S matrix and sandwich covariance
For subject OFV contributions, define subject score-like gradients. nlmx constructs
The quarter factor converts gradients of \(-2\log L_i\) to likelihood-score scale. \(S^{-1}\) is an outer-product-based covariance option. The default sandwich is \(R^{-1}SR^{-1}\), combining observed curvature with empirical across-subject score variation.
Sandwich covariance is often described as robust to some likelihood misspecification under asymptotic conditions. It is not immunity to wrong data, dependence, small samples, nonidentifiability or failed optimization. Subjects—not observations—supply independent score units.
The frozen two-parameter example shows different SEs under R, S and sandwich. The difference is expected because the matrices encode different information, not evidence that one implementation is broken.
Practical interpretation
Inspect subject score vectors before summing them. A few long vectors can dominate S, revealing influential subjects or design strata. The sandwich may then differ markedly from \(R^{-1}\). Investigate those contributions and subject independence rather than automatically labeling the larger SE “more conservative.” Robust theory still depends on appropriate clustering and adequate numbers of independent subjects.
If a study has centers, occasions or related subjects, the independence unit may require a clustered formulation not represented by simple subject-level S. State this limitation rather than overstating robustness.
Common mistakes
Do not build S from observation scores when subjects are the independent units, or claim robustness in a tiny sample. Do not confuse \(R^{-1}SR^{-1}\) with a random-effect covariance.
Checklist
- Verify subject-level contributions sum to OFV.
- Retain the quarter scaling.
- State R, S or sandwich choice.
- Review sample-size adequacy.
- Compare implementations using the same convention.
Further reading
Open csvcovariance_example.csv and its graphic, then continue to SEs.