Skip to content

Add pooling argument to analyse_mi_data() for unknown imputation methods - #52

Open
bailliem wants to merge 15 commits into
mainfrom
50-analyse_mi_data-when-the-exact-imputation-method-is-unknown
Open

Add pooling argument to analyse_mi_data() for unknown imputation methods#52
bailliem wants to merge 15 commits into
mainfrom
50-analyse_mi_data-when-the-exact-imputation-method-is-unknown

Conversation

@bailliem

@bailliem bailliem commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Closes #50

Summary

analyse_mi_data() can now analyse an already-imputed (ADMI) dataset when the imputation method is unknown, via a new pooling argument — addressing the scenario raised in #50 where the method object is unavailable.

  • New pooling argument ("rubin", "bootstrap", "jackknife", "bmlmi"): supply either method (unchanged behaviour, fully backward compatible) or pooling directly. Both together must agree; neither errors informatively.
  • New exported helper get_pooling(method) — the single source of truth mapping rbmi method objects to pooling strategies (as proposed in analyse_mi_data() when the exact imputation method is unknown. #50).
  • When only pooling is supplied, the data defines the number of imputations (no n_samples check) and an internal stand-in method object sized to the data is constructed so rbmi::pool() validation passes. print()/summary() label these objects <not supplied; pooling = "rubin"> rather than claiming a method that was never given.
  • pooling = "rubin" is the documented recommendation for data of unknown provenance; "bmlmi" alone errors (D not inferable from data); "bootstrap" with < 2 imputations errors rather than silently pooling to NAs.
  • Design spec and implementation plan included under docs/superpowers/; also fixes pre-existing roxygen unresolved-link warnings for @noRd internals in ard_conversion.R.

The pooling/get_pooling() design is deliberately shaped to be liftable into rbmi core per openpharma/rbmi#589.

Test plan

  • 95 tests in test-analyse_mi_data.R (34 new): validation error paths, method/pooling conflict, path-equivalence (pooling-only vs method produce identical pooled results), end-to-end rbmi::pool() for rubin/bootstrap/jackknife stand-ins, provenance labelling, guards.
  • 7 new tests in test-get_pooling.R covering all four method classes and error paths.
  • Full suite: 1075 passing; 2 pre-existing test-utils.R failures are a local rstan/Rcpp toolchain issue unrelated to this change.

bailliem added 8 commits July 30, 2026 10:38
Tags the constructed stand-in method with class rbmiUtils_standin so
print.analysis()/summary.analysis() report it as "<not supplied;
pooling = "...">" instead of fabricating Bayesian/condmean provenance
(F1). Adds coverage for the bootstrap pooling-only path and folds a
rbmi::pool() success assertion into the jackknife test (F2). Guards
make_standin_method() against bootstrap with fewer than 2 imputations,
which previously built n_samples = 0 and pooled to NAs silently (F3),
and adds a default switch() arm that aborts informatively on an
unrecognized pooling string (F4). Also removes a stray double blank
line, documents the condmean else-branch assumption in get_pooling(),
and notes in analyse_mi_data()'s @param pooling that the returned
method element is a constructed stand-in, not the true method (F5, F6).
compute_rubin_diagnostics() is @nord so no help topic exists; roxygen
link syntax [compute_rubin_diagnostics()] emitted unresolved-link
warnings on document(). Includes RoxygenNote bump to 7.3.3.
@bailliem bailliem linked an issue Jul 30, 2026 that may be closed by this pull request
@bailliem
bailliem marked this pull request as draft July 30, 2026 09:25
@bailliem bailliem self-assigned this Jul 30, 2026
@bailliem
bailliem marked this pull request as ready for review July 30, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

analyse_mi_data() when the exact imputation method is unknown.

1 participant