Case-mix and Context Decomposition

Why a model behaves differently at the next hospital

When a prediction model behaves differently at two hospitals, this method says whether that is because they see different patients or because comparable patients respond differently there.

Period
2025–2026
Role
Lead author
Status
Under review · MIT package
Stack
Python, R, PyTorch, scikit-learn, Autoencoders, Local regression

Problem

Prognostic models are often built from several data sources at once: hospitals in a multi-center study, registries, separate trials. The relationships those sources produce rarely agree. Standard meta-analytic measures such as coefficient-level tau-squared say how far apart they are but not why, and the two possible answers point in opposite directions. If the sources enrolled different kinds of patients, one pooled model is still defensible. If comparable patients follow different relationships, pooling averages incompatible effects into one that fits nobody.

Approach

At the study level the two causes look identical, so the question has to be asked one patient at a time. An autoencoder trained on reconstruction, local prognostic, and native-site terms learns a low-dimensional representation of patient characteristics. Ridge-stabilized local regressions then estimate a coefficient vector at each patient’s position in that space, using only observations from that patient’s own site, and kernel-ridge surfaces smooth the coefficients so sites can be compared at matched patient profiles. Partitioning those surfaces separates a cross-site position component from a site-specific context component, which the method projects onto the outcome scale to give observation- and site-level summaries.

Outcome

The method was applied to a clinical trial with two participating centers. In the leading coordinates of the learned representation, the gap between the two sites’ coefficients came mostly from context rather than from patient mix: comparable patients did not respond the same way at both centers. Carried back to the outcome scale, the difference between the sites concentrates in context too, with case mix accounting for close to none of it. Rerunning the pipeline with the site labels shuffled at random cut that contextual signal by more than a factor of ten, which is what should happen if the labels carry nothing. The manuscript is under review.

The implementation is released as a package under MIT. No trial data ships with it: the worked example is synthetic, generated from a fixed seed by a script in the repository, and only aggregate results leave the pipeline. Every run records the seed, the Python and PyTorch versions, and hashes of the configuration and the input, so a later run on the same setup can be checked against the first.