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

Chapter 5 Code 5.19: Effect of marriage on divorce A->M->D #163

Open
Jaskanwal opened this issue Oct 24, 2021 · 1 comment
Open

Chapter 5 Code 5.19: Effect of marriage on divorce A->M->D #163

Jaskanwal opened this issue Oct 24, 2021 · 1 comment

Comments

@Jaskanwal
Copy link

Jaskanwal commented Oct 24, 2021

In code 5.19, it feels like the effect of marriage on divorce should be captured as follows:
mu = pm.Deterministic("mu", a + bA * age_shared + bM * marriage)
i.e., the variable marriage_shared should be replaced by marriage.

I am trying to understand how A->M->D relationship is captured when running 5.21 for the values of A specified in 5.20. In the current formulation, the variable marriage_shared is controlling the A->M-D relationship and my understanding is this is set equal to data["MedianAgeMarriage_std"].value. I believe this can have an effect on counterfactual plots (Figure 5.6 left) due to A->M->D dependence (if any).

@Jaskanwal Jaskanwal changed the title Chapter 5 Code 5.19: Effect of marriage on Divorce Chapter 5 Code 5.19: Effect of marriage on divorce A->M->D Oct 24, 2021
@jaredsnyder
Copy link

jaredsnyder commented Dec 29, 2021

I noticed the same issue, I tried to fix it by updating the code to look like this:

# With PyMC3 we have to simulate in each model separately

 

# Simulate the marriage rates at each age first

age_shared.set_value(A_seq)

 

with m5_3_A:

    m5_3_M_marriage = pm.sample_posterior_predictive(m5_3_A_trace, samples=1)

    marriage_shared.set_value(m5_3_M_marriage['marriage'].flatten())

    m5_3_M_marriage = pm.sample_posterior_predictive(m5_3_A_trace)

It didn't seem to effect the plots but I could see that being the result of D being independent of M conditioned on A (or as a result of a mistake I made in attempting a fix)

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

2 participants