Missing Data
Missing data can change the population represented in an analysis and the uncertainty of its estimates. This section compares methods on one invented cohort, from complete-case analysis through multiple imputation with mice and miceforest. It then examines diagnostics and sensitivity to the missingness assumptions.
Every page pairs R and Python in synced tabs, and every number and figure comes from a real run of the code shown, in one pinned container, in both languages. The basics of detecting and filling missing values live in Missing Values; this section is about what to do when filling is not enough.
The LC-MS quality lesson preserves absent feature measurements separately from measured zero. Its paired comparison reports complete pairs without an assumed replacement for each absent measurement.
The cohort with the answer key
Section titled “The cohort with the answer key”All five pages compute on one synthetic cohort of 400 patients: age, body mass index, activity, smoking, cholesterol and systolic blood pressure, with missingness introduced deliberately into the last four. The complete version of the cohort is kept beside the missing one. This permits comparisons with the hidden cell values and with the regression fitted to the complete cohort. The interval table checks inclusion of those complete-data estimates in this one example. It does not estimate confidence interval coverage over repeated studies.
Naturally missing values do not have a known answer key. Diagnostics and sensitivity analyses remain necessary. Artificially hiding observed values can assess prediction on that selected subset, but it does not establish accuracy for the naturally missing values.
The path
Section titled “The path”| Page | What it does |
|---|---|
| Missing Data Mechanisms | MCAR, MAR and MNAR, pattern tables, and the one mechanism question the data can answer |
| Simple Imputation and Its Cost | deletion, mean, median, mode and kNN, each fitted and measured against the benchmark |
| Multiple Imputation with mice and miceforest | m imputations and Rubin’s rules, with the between-imputation disagreement priced into the standard error |
| Choosing the Imputation Model | predictor screening, typed methods, and the measured difference between mean matching and a posterior draw |
| Evaluating Imputation Quality | convergence, distributions, comparison with the complete-data fit, and sensitivity to departures from MAR |
Two engines, one contract
Section titled “Two engines, one contract”The R tabs use mice, the reference implementation of multiple imputation by
chained equations, with VIM for the nearest-neighbour method. The Python tabs
use miceforest, whose mean-matched gradient boosting plays the same role.
Both implementations use the same cohort and analysis formula. Their imputation models differ, so the completed values and pooled estimates can differ. The pages report those differences instead of requiring artificial agreement.
The companion directory contains the runners, container definition, and fixture generator. It requires repository access. The examples read the container’s committed fixtures from /opt/data; those paths are not ordinary files on a reader’s computer.
These pages concern inference after multiple imputation. For predictive models, fit preprocessing inside the training partition as described in scikit-learn pipelines. A completed dataset prepared before the split can leak information across that split.
Further reading
Section titled “Further reading”The mice reference manual defines the imputation methods, predictor matrix and pooling rules.