I am solving exercise 2.4.1 part a) from Pearl et al. "Causal Inference in Statistics: A Primer" (2016).

enter image description here

I have found that in Figure 2.9, variables $Y$ and $Z_1$ are independent conditional on variables $\{X, Z_2, Z_3\}$: $$ Y \perp \!\!\! \perp Z_1 | \{X, Z_2, Z_3\}. $$ (The same answer is found in the Solution Manual.) I want to illustrate this empirically, so I generate data that is compatible with the graph as follows (in R):

set.seed(1); Z1=rnorm(n)
set.seed(2); Z2=rnorm(n)
set.seed(3); Z3=rnorm(n)+Z1+Z2
set.seed(4); X=rnorm(n)+Z1+Z3
set.seed(5); W=rnorm(n)+X
set.seed(6); Y=rnorm(n)+W+Z1+Z2

I then estimate a model $$ Y=\beta_0+\beta_1 Z_1+\beta_2 Z_2+\beta_3 Z_3+\beta_4 X+\varepsilon $$ and expect to find that $\hat\beta_1$ is not statistically significant because of the conditional independence mentioned above. However, the result is out of line:

> m1=lm(Y~Z1+Z2+Z3+X)
> summary(m1)

lm(formula = Y ~ Z1 + Z2 + Z3 + X)

    Min      1Q  Median      3Q     Max 
-5.7134 -0.9562 -0.0052  0.9533  6.7408 

             Estimate Std. Error t value Pr(>|t|)    
(Intercept) -0.009183   0.004500  -2.041   0.0413 *  
Z1           0.993558   0.007770 127.868   <2e-16 ***
Z2           1.002707   0.006349 157.923   <2e-16 ***
Z3          -0.009440   0.006354  -1.486   0.1373    
X            1.008032   0.004507 223.636   <2e-16 ***
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.423 on 99995 degrees of freedom
Multiple R-squared:  0.8817,    Adjusted R-squared:  0.8817 
F-statistic: 1.863e+05 on 4 and 99995 DF,  p-value: < 2.2e-16

This could of course be an unlucky case. I have tried a few other random seeds for generating data, but I am consistently getting a highly significant $\hat\beta_1$. ($\hat\beta_3$ becomes significant in many other cases, as I think it should be.)

What am I doing wrong?

By the way, I have assessed conditional independence between several other pairs of variables in Figure 2.9, and there I am getting the expected results from the same simulated data (just different regressions).

  • $\begingroup$ Hey, Richard! I'm working my way through the same book. I'm up to Study question 4.3.1, and finally hit a fairly hard roadblock. If you have any ideas, I'd love to have them! It's my question on the Counterfactual Expectation Calculation. $\endgroup$ Commented Apr 2, 2020 at 14:32
  • $\begingroup$ @AdrianKeister, I have not got that far in the book yet myself. $\endgroup$ Commented Apr 2, 2020 at 14:58

1 Answer 1


I think your code for simulating the data has a typo. In the line beginning with set.seed(6) $Z_1$ should be $Z_3$.

  • $\begingroup$ That was indeed a typo. Funnily enough, it did not mess up any of the other results that I tested! I guess there might have been other typos there :) $\endgroup$ Commented Mar 25, 2020 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.