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 hierarchical causal model specified in pyro #261

Open
djinnome opened this issue Dec 20, 2024 · 0 comments
Open

Identify hierarchical causal model specified in pyro #261

djinnome opened this issue Dec 20, 2024 · 0 comments

Comments

@djinnome
Copy link
Contributor

create figure 2 models in pyro. use render_model to export to dot so that it can be read into pygraphviz.

import pyro

def figure_2a_confounder():
    """
    Simulates the confounder model for Figure 2(a) in the paper.
    """
    # Define the confounder model
    def confounder_model():
        # Define the prior distribution for the confounder variable
        confounder = pyro.sample("U", dist.Uniform(0.0, 1.0))
        # Define the prior distribution for the treatment variable
        with pyro.plate("students", 10):
            treatment = pyro.sample("A", dist.Bernoulli(confounder))
        # Define the prior distribution for the outcome variable
            outcome = pyro.sample("Y", dist.Normal(confounder + 2.0 * treatment, 1.0))
        return outcome
    return confounder_model

pyro.render_model(figure_2a_confounder(), render_deterministic=True, filename="confounder.dot")

confounder.dot.txt
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant