Skip to content

Commit 7595fdb

Browse files
committed
add IV-type score error for binary outcome
1 parent d4936a0 commit 7595fdb

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

doubleml/plm/plr.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ def __init__(
9696
self._is_cluster_data = self._dml_data.is_cluster_data
9797
valid_scores = ["IV-type", "partialling out"]
9898
_check_score(self.score, valid_scores, allow_callable=True)
99+
if self.score == "IV-type" and obj_dml_data.binary_outcome:
100+
raise ValueError("For score = 'IV-type', additive probability models (binary outcomes) are not supported.")
99101

100102
ml_l_is_classifier = self._check_learner(ml_l, "ml_l", regressor=True, classifier=True)
101103
ml_m_is_classifier = self._check_learner(ml_m, "ml_m", regressor=True, classifier=True)

doubleml/plm/tests/test_plr_binary_outcome.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ def test_dml_plr_binary_exceptions(generate_binary_data, learner_binary, score):
6767
with pytest.raises(ValueError, match=msg):
6868
_ = dml.DoubleMLPLR(obj_dml_data, clone(learner_binary), clone(learner_binary), score=score)
6969

70+
# IV-type not possible with binary outcome
71+
obj_dml_data = dml.DoubleMLData(data, "y", ["d"])
72+
msg = r"For score = 'IV-type', additive probability models \(binary outcomes\) are not supported."
73+
with pytest.raises(ValueError, match=msg):
74+
_ = dml.DoubleMLPLR(obj_dml_data, clone(learner_binary), clone(learner_binary), score="IV-type")
75+
7076

7177
@pytest.fixture(scope="module")
7278
def dml_plr_binary_fixture(generate_binary_data, learner_binary, score):

0 commit comments

Comments
 (0)