Skip to content

warn when restricted_mean_survival_time(return_variance=True) is used#1683

Open
laurapiro17 wants to merge 2 commits into
CamDavidsonPilon:masterfrom
laurapiro17:fix/1682-warn-return-variance
Open

warn when restricted_mean_survival_time(return_variance=True) is used#1683
laurapiro17 wants to merge 2 commits into
CamDavidsonPilon:masterfrom
laurapiro17:fix/1682-warn-return-variance

Conversation

@laurapiro17

Copy link
Copy Markdown

refs #1682.

restricted_mean_survival_time(..., return_variance=True) returns Var[min(T, t)] (variance of the truncated survival RV), not the sampling variance of the RMST estimator. anyone using it for confidence intervals or hypothesis tests silently gets the wrong answer — on the bundled waltons miR-137 subset at τ=10 the reported SE is ~6× the survRM2/greenwood reference.

this PR is the smallest fix while #1526 (greenwood-based variance) is in review:

  • emits a UserWarning when return_variance=True is used
  • updates the docstring to spell out what is actually returned
  • wraps the existing tests that touch return_variance=True with pytest.warns
  • adds a new test covering both the model and survival_function_ paths, and that the default call stays silent

doesn'''t change the numeric return value or implement greenwood — that belongs in #1526.

tested locally: pytest -k rmst → 7 passed.

The returned value is Var[min(T, t)] (variance of the truncated
survival random variable), not the sampling variance Var[RMST_hat]
of the estimator, and is therefore unsuitable for confidence intervals
or hypothesis tests on RMST. Users were silently constructing wrong
inference (see the reproduction in CamDavidsonPilon#1682, ~6x SE inflation on the
bundled waltons miR-137 subset).

Emit a UserWarning when return_variance=True is passed and document
the semantics in the docstring. Add a test covering both the model
and survival-function code paths.

Refs CamDavidsonPilon#1682.
Silence the UserWarning emitted in two existing RMST tests
(test_rmst_works_at_kaplan_meier_with_left_censoring and
test_rmst_variance) by asserting the warning is raised, rather than
leaking it to test output.
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.

1 participant