pgmpy / pgmpy

Python Library for learning (Structure and Parameter), inference (Probabilistic and Causal), and simulations in Bayesian Networks.

Home Page:https://pgmpy.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How should I calculate P(Y|do(X),Z∈{1,2,3}) ?

Anditty opened this issue · comments

Subject of the issue

In class pgmpy.inference.CausalInference.CausalInference , I can use function query(variables, do=None, evidence=None, adjustment_set=None, inference_algo='ve', show_progress=True, **kwargs) to calculate P(Y|do(X),Z=1), but I can't calculate P(Y|do(X),Z∈{1,2,3}) bucause the type of parameter evidence is dict. So I want to know How should I calculate P(Y|do(X),Z∈{1,2,3}) ? Thanks for your answer!

@Anditty I am not exactly sure what you mean by computing P(Y|do(X), Z \in {1, 2, 3}? Do you like an or operation where Z can be in either of the three states? If yes, there is no direct way to do that but you would run 3 separate inferences and join the result as: \sum_{i={1, 2, 3}} P(Y | do (Y), Z = i)

@ankurankan Thanks for your answer! But I don't think \sum_{i={1, 2, 3}} P(Y | do (X), Z = i) = P(Y | do (X), Z = 1 or Z = 2 or Z = 3). It should be P(Y | do (Y), Z = 1 or Z = 2 or Z = 3) = \sum_{i={1, 2, 3}} P(Y | do (X), Z = i)*P(Z=i)/P(Z= 1, 2, 3)