-
Notifications
You must be signed in to change notification settings - Fork 99
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
weight matrix in IPW calculation can have weights info due to division by zero #9
Comments
Thanks for the input. One possible solution to avoid zero-propensities would be to clip your propensities. That can be done with the from causallib.estimation import IPW
ipw = IPW(truncate_eps=0.01) will clip all propensity scores between 0.01 and 0.99, so all your zeros will become 0.01, thus evading a division by zero when inverting the scores into weights. Alternatively, you can first obtain the weights, manipulate them as you wish, and then provide them to the potential outcomes estimation: w = ipw.compute_weights(X, a)
# Manipulate `w` as you wish (also the corresponding `X, a, y` if needed)
outcomes = ipw.estimate_population_outcome(X, a, y, w) Theoretical contextSo those were technical data manipulations to work around zero-propensities. As for your case, if I may suggest, you might want to try to evaluating your model, and possibly detect where the problem originates from: from causallib.evaluation import PropensityEvaluator
evaluations = evaluator.evaluate_simple(
ipw, X, a, y,
plots=["roc_curve"", "weight_distribution", "covariate_balance_love", "calibration"]
) ¹The positivity assumption is formulated as |
I'll be happy to know if that helped you solve your problem, or get any feedback relating to whether this approach makes sense to you. |
weight_matrix = probabilities.rdiv(1.0) statement in this file can return inf weights if some entries in "probabilities" series are zero. Maybe there could be some way to ignore the corresponding inf weights while applying weight_matrix later on.
The text was updated successfully, but these errors were encountered: