Skip to content

A few amends and add some real tests in addition to smoke tests#161

Merged
remlapmot merged 23 commits into
mainfrom
devel-2026-06-02
Jun 8, 2026
Merged

A few amends and add some real tests in addition to smoke tests#161
remlapmot merged 23 commits into
mainfrom
devel-2026-06-02

Conversation

@remlapmot

Copy link
Copy Markdown
Collaborator

Hi Ryan,

PR from last week's work.

  • From a SEQuential() fit, populate weight.statistics and outcome.model when hazard = TRUE.
  • Warn when the numerator and denominator weight models are given identical covariates. In that case the stabilized weights all equal 1 (i.e., no weighting), which is usually a typo in the denominator argument.
  • Improve the SEQuential() helpfile by adding a per-protocol example.
  • Add behavioural tests that selection.random = TRUE retains all treated trial-starts, subsamples control trial-starts to the requested selection.prob fraction, and is reproducible under a fixed seed; rename the previous smoke test that did not actually exercise the feature.
  • Add behavioural tests for; weight.lower/weight.upper truncation, weight.p99 truncation, followup.include/trial.include, followup.class, weight.lag_condition, followup.min/followup.max, and weight.eligible_cols.
  • Fix numerator() and denominator() returning NULL for every weighted model; they now return the fitted per-arm numerator/denominator weight models.
  • Document that weight truncation applies only to the outcome-model fit.
  • Pass the formula cache to inline.pred() in the weight models
  • Fix SEQOpts() argument ordering.

remlapmot added 23 commits June 2, 2026 15:43
Replaces reliance on a smoke test: verifies the truncation is actually
applied to the weights used in the outcome fit. Two clamp bands entirely
above the weight range collapse all weights to a constant and, by GLM
scale-invariance, give identical coefficients, while a genuinely
varying-weight fit differs.
Verifies weight.p99 = TRUE is equivalent to explicitly setting
weight.lower/weight.upper to the p01/p99 reported in weight.statistics,
and that it differs from an untruncated weighted fit.
Verifies each flag adds or drops its follow-up / trial terms (and their
squares) in the fitted outcome-model coefficients, leaving the other
flag's terms intact.
Verifies followup.class = TRUE encodes follow-up as a factor: the linear
followup / followup_sq terms are gone and there is one dummy coefficient
per non-reference follow-up level.
Previously untested. Verifies weight.lag_condition = TRUE fits each
arm's weight model only on its treatment-lag stratum (per-arm
observation counts differ and sum to the full data), while FALSE fits
both arms on the full data (equal counts).
Verifies the expanded data (via expand.only) is clamped to the requested
[followup.min, followup.max] window, while the unrestricted expansion
spans beyond it.
Verifies each arm's weight model is fit only on rows where its
weight.eligible_cols indicator == 1, by checking the per-arm denominator
observation counts drop versus an unfiltered fit.
They looked up non-existent fields (n0.coef/d0.coef) instead of the coef.numerator/coef.denominator lists actually stored in
weight.statistics, so they silently returned NULL for every weighted model. Index the per-arm models correctly and guard the ITT case where no treatment-weight models exist. Add a regression test.
Clarify in the weight.lower/weight.upper/weight.p99 docs that
weight.statistics and the returned data report the untruncated weights; truncation affects only the weights used to fit the outcome model.
Routes the weight numerator/denominator/LTFU/visit predictions through the cached formula path, matching the survival and hazard paths. Results are bit-identical; this is a consistency cleanup, not a perf change.
@remlapmot remlapmot requested a review from ryan-odea June 8, 2026 12:16

@ryan-odea ryan-odea left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look good!

@remlapmot remlapmot merged commit ea65b42 into main Jun 8, 2026
7 checks passed
@remlapmot remlapmot deleted the devel-2026-06-02 branch June 8, 2026 13:16
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.

2 participants