py-why / dowhy

DoWhy is a Python library for causal inference that supports explicit modeling and testing of causal assumptions. DoWhy is based on a unified language for causal inference, combining causal graphical models and potential outcomes frameworks.
https://www.pywhy.org/dowhy
MIT License
7.11k stars 933 forks source link

do sampling only works for backdoor, it does not work for front door, instrumental variables of unobserved confounders #812

Closed grahamharrison68 closed 1 year ago

grahamharrison68 commented 1 year ago

Ask your question I have created causal models and estimands for a range of cases - backdoor, front door, instrumental variable and also for where front door and instrumental variables have unobserved confounders. All of these work for calculating the ate.

I have now tried to run the do operator for a graph where there is an instrumental variable and an unobserved backdoor confounder but it crashes with KeyError: 'backdoor'

The do operator only works where there is an observed backdoor confounder which is very disappointing as it rules out a lot of use cases.

Here is the code ...

variable_types = {'engagement': 'd', 'retention': 'd', 'funding': 'd'} gml_graph = 'graph [directed 1\n\tnode [id "funding" label "funding"]\n\tnode [id "engagement" label "engagement"]\n\tnode [id "retention" label "retention"]\n\tnode [id "U" label "U"]\n\tedge [source "funding" target "engagement"]\n\tedge [source "engagement" target "retention"]\n\tedge [source "U" target "engagement"]\n\tedge [source "U" target "retention"]\n]'

df_do = df_student_retention.causal.do(x={"engagement": 1}, outcome="retention", dot_graph=gml_graph, variable_types=variable_types, proceed_when_unidentifiable=True)

Expected behavior I would expect df_do to be populated with the results of the do operation

Version information: 0.9

Additional context As stated above, it all works for calculating the ate, just not for running a "do" operation

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 14 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 7 days since being marked as stale.