Skip to content

Package validation and Monte Carlo cache

The vitaldb_resolution package returns a status for every value in the dataset, reproduces each fitted likelihood, and can precompute every posterior for fast Monte Carlo draws.

Date 2026-10-13
Status current
Methods Rounding, heaping and value resolution

Background

  • The API takes a VitalDB variable name and a recorded value and returns a distribution over true values. Single-resolution variables get one uniform component; heaped variables get a mixture over rounding modes.

Data

  • 6,388 cases × 79 clinical variables (504,652 variable-case cells) and all 928,448 lab results.

Method

  • Ran the full dataset through the package (tools/validate.py) and compared each model's log-likelihood with the stored one.
  • Built quantile tables for posteriors from fitted models and compared knot counts, storage types and knot placement.

Results

  • Clinical statuses: 217,111 ok, 61,129 zero or not recorded, 45,533 missing, 178,864 not applicable, 1,987 imputed, 20 invalid, 8 top-coded. All lab results are ok, with 19 off-grid flags.
  • The clinical pass takes 7 min and the lab pass 10 min on one core.
  • The cache holds the whole dataset in about 214 MB. One iteration draws every value in about 20 ms for the cases and about 75 ms including all lab results.
  • At any number of knots, int16 has the same worst-case error as float32 and float64. The default is 1,024 knots in int16, with worst mean error 4.7 × 10⁻⁴ SD.
  • Knot placement mattered more than either. End knots at the support ends inflated the SD by up to 80 % at 256 knots; interior knots with tail-mean-preserving end knots cut the worst SD error to 1.1 % and 0.42 %.
  • Since vitaldb-resolution v0.6.0 (18 October; model version 2): each result's density within a rounding interval comes from the fitted latent at call time (uniform only where no latent is fitted), and every result names its density, model id, version and fit hash. The latent and uniform means differ by a few per cent of the interval near the median and by 0.2–0.45 of its width at small values and at the edges. Models are versioned (v1 archived and still loadable, models.lock per release), every stored log-likelihood now matches the recomputed one, and the registry records each anchor's basis.

Discussion

  • The default's worst mean error is about 20 times smaller than the Monte Carlo standard error after 10,000 iterations.
  • Building the package surfaced new rules: two out-of-range anaesthesia ends, 93 clock-offset mismatches, child native resolution, and a revised red-cell rule.

Limitations

  • Where a posterior has a gap between two rounding windows, draws can land inside it. This is the large point-wise quantile error (0.8 SD at the 99th percentile at 1,024 knots); it barely moves the mean, SD or W1.

Worked examples

Example Side Status Summary
A regression that carries rounding uncertainty through value draft Acute kidney injury after surgery against intraoperative urine output (mL/kg/h), fitted once on the recorded numbers and once per draw from the true-value distributions: the rounding moves 14% of cases across the oliguria threshold, but widens the confidence interval of the cohort's regression by at most 4%.

Tags: from the resolution work