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

Order of Action Nodes effects Identified Estimand #1250

Open
nparent1 opened this issue Sep 10, 2024 · 1 comment
Open

Order of Action Nodes effects Identified Estimand #1250

nparent1 opened this issue Sep 10, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@nparent1
Copy link
Contributor

DoWhy's has_directed_path method checks for a directed path between the action node at index 0, and outcome node at index 0. AutoIdentifier's identify_effect_auto method exits if there is no directed path.

Thus, if you call identify_effect_auto() with two action nodes, where one has a path to the (first) outcome node and the other does not, then you get different results.

The following two code snippets have one different line, action_nodes= ['treatment', 'independent_variable'] vs action_nodes= ['independent_variable', 'treatment']

The first:

from dowhy.causal_identifier import AutoIdentifier, EstimandType
Identifier = AutoIdentifier(EstimandType.NONPARAMETRIC_ATE)
causal_graph = """digraph {
treatment;
independent_variable;
outcome;
treatment->outcome;
}"""
G = to_nx_graph(causal_graph)   # code for to_nx_graph not in snippet
eff = Identifier.identify_effect(
    G,
    action_nodes= ['treatment', 'independent_variable'],
    outcome_nodes= ['outcome'],
    observed_nodes= ['treatment', 'independent_variable', 'outcome'],
)
print(eff)

This gives back

image

The second:

from dowhy.causal_identifier import AutoIdentifier, EstimandType
Identifier = AutoIdentifier(EstimandType.NONPARAMETRIC_ATE)
causal_graph = """digraph {
treatment;
independent_variable;
outcome;
treatment->outcome;
}"""
G = to_nx_graph(causal_graph)   # code for to_nx_graph not in snippet
eff = Identifier.identify_effect(
    G,
    action_nodes= ['independent_variable', 'treatment'],
    outcome_nodes= ['outcome'],
    observed_nodes= ['treatment', 'independent_variable', 'outcome'],
)
print(eff)

This gives back

image

  • DoWhy version 0.11.1
@nparent1 nparent1 added the bug Something isn't working label Sep 10, 2024
@nparent1
Copy link
Contributor Author

I noticed this when working on #654 in #1247

I believe that PR should also fix this issue, but wanted to open a separate issue in case it was preferred this got resolved another way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant