**************************************************************************************************** //step 1: create a program/function/command maing a single simulation **************************************************************************************************** capture program drop triangle program triangle, rclass clear ancestor C, pre1(0.1) popu(10000) child E C, baserisk(0.05) p1or(2) child D E C, baserisk(0.05) p1or(1) p2or(5) logistic D i.E mat A=r(table) return scalar or0=A[1,2] return scalar low0=A[5,2] return scalar up0=A[6,2] logistic D i.E i.C mat A=r(table) return scalar or1=A[1,2] return scalar low1=A[5,2] return scalar up1=A[6,2] end **************************************************************************************************** //step 2: To simulate 100 dataset reflecting the DAG **************************************************************************************************** simulate or0=r(or0) low0=r(low0) up0=r(up0) or1=r(or1) low1=r(low1) up1=r(up1), reps(100): triangle gen id=_n **************************************************************************************************** //Step 3: graphically display the 100 simulations **************************************************************************************************** ************************************************** //Q1: ************************************************** sum or0 two (sc or0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), name(p1, replace) ************************************************** //Q2: ************************************************** sum or1 two (sc or1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), name(p2, replace)