Skip to content

fix: carry over learners to the rebuilt sub-models in DoubleMLVector.sensitivity_benchmark - #441

Open
vrjdev wants to merge 3 commits into
DoubleML:mainfrom
vrjdev:fix-vector-sensitivity-benchmark
Open

vrjdev wants to merge 3 commits into
DoubleML:mainfrom
vrjdev:fix-vector-sensitivity-benchmark

Conversation

@vrjdev

@vrjdev vrjdev commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Description

DoubleMLVector.sensitivity_benchmark rebuilds the sub-models of the short-form model with _initialize_models(), so that they use the reduced covariate set. The new sub-models had no learners, because in the vector API the learners are only stored on the sub-models. Refitting the short-form model therefore always raised ValueError: Learner 'ml_l' is required but not set ..., and the method could not be used at all.

  • doubleml/double_ml_vector.py: after rebuilding, each new sub-model gets the learners of the sub-model it replaces.
    • The learners are taken from the deep copy, so nothing is shared with the original model.
    • Copying _learners keeps the full learner state created by set_learners (e.g. ml_g cloned from ml_l for the IV-type score). It works for any DoubleMLVector subclass, whatever the arguments of its set_learners.
  • doubleml/plm/tests/test_plr_vector_vs_plr.py: the new test_sensitivity_benchmark_equal checks that PLRVector.sensitivity_benchmark equals the legacy DoubleMLPLR.sensitivity_benchmark (rtol=1e-9). It covers both scores, both learners, and n_rep 1 and 3. All 8 cases fail before the fix.

Reference to Issues or PRs

Fixes #440

Comments

This only affects the unreleased vector API from #394.

PR Checklist

  • The title of the pull request summarizes the changes made.
  • The PR contains a detailed description of all changes and additions.
  • References to related issues or PRs are added.
  • The code passes all (unit) tests.
  • Enhancements or new feature are equipped with unit tests.
  • The changes adhere to the PEP8 standards.

…sensitivity_benchmark

DoubleMLVector.sensitivity_benchmark rebuilt the sub-models of the
short-form model with _initialize_models() so that they use the reduced
covariate set, but the new sub-models had no learners: in the vector API,
the learners are only stored on the sub-models. Refitting the short-form
model therefore always raised "Learner 'ml_l' is required but not set".
Give each rebuilt sub-model the learners of the sub-model it replaces.

Check that PLRVector.sensitivity_benchmark matches the legacy
DoubleMLPLR.sensitivity_benchmark.

This branch has not been deployed

No deployments
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.

[Bug]: DoubleMLVector.sensitivity_benchmark always fails because the short-form sub-models are rebuilt without learners

2 participants