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

Identify effect not showing backdoor variable #1048

Closed
asha24choudhary opened this issue Oct 16, 2023 · 5 comments
Closed

Identify effect not showing backdoor variable #1048

asha24choudhary opened this issue Oct 16, 2023 · 5 comments
Labels
question Further information is requested stale

Comments

@asha24choudhary
Copy link

Hi there. I was referring to this issue. I am having a dataset with both observed and unobserved confounder as described below

Create the graph describing the causal structure

graph = """graph[directed 1 node[id "U" label "U"]
node[id "X" label "X"]
node[id "Y" label "Y"]
node[id "Z" label "Z"]
edge[source "U" target "X"]
edge[source "X" target "Y"]
edge[source "U" target "Y"]
edge[source "Z" target "X"]
edge[source "Z" target "Y"]]""".replace('\n', '')

# # Generate the data

U = np.random.randn(N_SAMPLES)
Z = np.random.randn(N_SAMPLES)
X = np.random.randn(N_SAMPLES) + 0.3U +0.2Z
Y = 0.65X + 0.2U+ 0.3*Z

df = pd.DataFrame(np.vstack([Z,X, Y]).T, columns=['Z','X', 'Y'])
print(df.head(10))

Create a model

model = CausalModel(
data=df,
treatment=['X'],
outcome=['Y'],
common_causes=['Z'],
graph=graph
)
model.view_model()
plt.show()

I expect to have backdoor variable but
image
as you can seen the estimate says 'Backdoor identification failed'. I don't know what is wrong and how can I resolve this?

Could you please help me?

@asha24choudhary asha24choudhary added the question Further information is requested label Oct 16, 2023
@github-actions
Copy link

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

@github-actions github-actions bot added the stale label Oct 31, 2023
@amit-sharma
Copy link
Member

The error you are seeing is unrelated to the linked issue.
In your case, the only valid backdoor set is $[U, Z]$, but since U is unobserved, identify_effect method returns that backdoor identification is not possible.

Note that graph argument takes precedence in CausalModel. So if you only want to condition on Z, you have can do so if by initializng CausalModel directly, without the graph.

model = CausalModel(
data=df,
treatment=['X'],
outcome=['Y'],
common_causes=['Z']
)

@github-actions github-actions bot removed the stale label Nov 5, 2023
@asha24choudhary
Copy link
Author

Thank you for your reply @amit-sharma, I reason why i linked the previous issue is because I wanted to include unobserved confounder. But don't you think I should include the graph which contains the info about the unobserved confounder 'U', which is also done in the issue I linked?

I was assuming that in order to have unobserved confounder, I should include it in the graph which is used while creating the model and exclude it in the dataset.

Yes if I exclude the graph while modelling, then the valid backdoor path includes Z. However, my question to u now is that should I not include the graph & why, because don't you think if I do so then I lose the info about the unobserved confounder in the model, of course it is still present in the data?

Would be really helpful if you could explain a bit more in detail.

Copy link

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

@github-actions github-actions bot added the stale label Nov 22, 2023
Copy link

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

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested stale
Projects
None yet
Development

No branches or pull requests

2 participants