Please find attached
Looks good Francois although I don't see the direct output results. Since you don't show the distribution of the p-values across your simulations, I have to take your word for it that none of the iterations predicted a p-value above the alpha threshold of .05.
Your notation conveys that you are representing counterfactuals or potential outcomes, rather than observed contrasts. For example when you use superscripts to denote the X=x, it is usually interprreted as the potential outcome of the variable, when X is set to x. Whereas you say E(Y|X=x) to refer to the average value of Y among those observations with X=x (ie the observed outcomes).
Hi Maria,
Thx for the clarification on counterfactuals vs observed average values. I have modified my answer, also cause I wanted to see what happens if I could adjust on the confounder U and I am still confused... Under a true null effect of X on Y:
- When I don't adjust for U, I found selection bias for both S1 and S2. Given my DAG, I though restricting to S2=1 would not induce selection bias and if anything would account a bit for the confounding bias induced by U. Any thoughts?
- When I do adjust for U, I found no selection bias for neither S1 and S2. Given my DAG, I expected S1 to induce bias. Any thoughts on why I am correctly observing a null effect in spite of restricting to S1=1? (Maybe my code is just wrong)
As for type-1 error, the code line:
100*sum(as.numeric(simulationoutput$pvalue<0.05))/length(simulationoutput$pvalue)
simply computes the proportion of bootstrap p-values that reached the alpha=0.05 level under the null, so yes please take my word for it :).
Thx