**************************************************************************************************** //Download Stata commands **************************************************************************************************** *Type and run "ssc describe dag" in the Stata command window. You should be able to view and download the commands. ************************************************** //Step 1: Identify ancestor-variables and child-variables ************************************************** *ancestor-variables: C *child-variables: E, D **************************************************************************************************** //To simulate a dataset reflecting the DAG **************************************************************************************************** clear set seed 11 ************************************************** //Step 2: simulating ancestor-variables ************************************************** ancestor C, pre1(0.1) popu(10000) //Note: *1, prevalence of C=0.1 *2, population size = 10000 ************************************************** //Step 3: simulating child-variables ************************************************** child E C, baserisk(0.05) p1or(2) //Note: *1, risk of E = 0.05 when C=0 *2, Causal odd ratio from C to E = 2 child D E C, baserisk(0.05) p1or(1) p2or(5) //Note: *1, risk of D = 0.05 when C=0 and E=0 *2, Causal odd ratio from E to D = 1 *3, Causal odd ratio from C to D = 5 **************************************************************************************************** //Step 3: To quantify the assocations **************************************************************************************************** ************************************************** //Quantify the association between the variable E and D without adjusting for C ************************************************** logistic D i.E ************************************************** //Quantify the association between the variable E and D adjusting for C ************************************************** logistic D i.E i.C