Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added warning message and test for issue #837 #919

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions econml/iv/dml/_dml.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,19 @@ def predict(self, Y, T, X=None, W=None, Z=None, sample_weight=None, groups=None)
TX_pred = np.tile(TX_pred.reshape(1, -1), (T.shape[0], 1))
Y_res = Y - Y_pred.reshape(Y.shape)
T_res = TXZ_pred.reshape(T.shape) - TX_pred.reshape(T.shape)
if not T_res.any():
raise ValueError(
"""
All values of the treatment residual are 0,
which then makes them unsuitable to use as weights.
DRIV requires that the instrument Z has an effect on the
expected treatment value of at least some rows.

If you are using regularized models, it's possible that this error is a
result of regularizing too strongly, so that all predictions from both
models are constant.
"""
)
return Y_res, T_res


Expand Down
Loading