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

Frontdoor estimation is wrong #971

Closed gabrielgorenroig closed 11 months ago

gabrielgorenroig commented 1 year ago

Hi, I am turning a comment I made on another issue around 8 months ago into a separate issue since it has not been resolved and I believe it to be a crucial bug that stops DoWhy from being usable in many scenarios.

Consider the following DAG:

1

In this case {M} should not satisfy the frontdoor criterion, although {M, R} would. However dowhy identifies {M} as an adjustment set.

2

The desired behavior, if I understand it correctly, is that it should return {M, R} or {M, E} as frontdoor adjustment sets if either of E and R are observable, and should return no frontdoor variables found if both R and E are declared as unobservable.

I have been looking at the source code but I haven't found where it might be going wrong. What I did learn is that, apparently, only 1-variable frontdoor adjustment sets are supported for the moment !? I think it would be important that this would be specified in the documentation. But in any case, I would consider the situation above to be a serious bug (the call should at least return that no 1-variable frontdoor adjustment sets are found).

Originally posted by @gabrielgorenroig in https://github.com/py-why/dowhy/issues/284#issuecomment-1335909744

amit-sharma commented 1 year ago

thanks for raising attention to this @gabrielgorenroig Let me take a look and add support for multiple nodes. \

Display-ST commented 1 year ago

I also have a problem with the front door estimation in dowhy (v0.10.1). The set {M1, M2} satisfies the front door criteria when X, Y, and Z are the treatment, outcome, and confounder, respectively, but the following output is obtained from identify_effect. Here is the code. Thank you.

Estimand type: EstimandType.NONPARAMETRIC_ATE

### Estimand : 1
Estimand name: backdoor
No such variable(s) found!

### Estimand : 2
Estimand name: iv
No such variable(s) found!

### Estimand : 3
Estimand name: frontdoor
No such variable(s) found!

image

amit-sharma commented 11 months ago

Thanks @gabrielgorenroig and @Display-ST for raising these issues. They are now fixed via #1093