******************************************************************************** //model 1 ******************************************************************************** *- step 1 定义模型的数值模拟程序 *model 1 模拟程序 capture program drop model_1 //模型命名为model_1,若有更换注意修改 program model_1,rclass //若有更换注意修改 clear set obs 10000 *此部分为针对不同模型结构需要修改的部分 *************************** *model 1 :DAG结构 gen z = rnormal() gen x = z + rnormal() gen y = x + z + rnormal() *************************** *不控制z reg y x mat A=r(table) return scalar mean0=A[1,1] return scalar low0=A[5,1] return scalar up0=A[6,1] *控制z reg y x z mat A=r(table) return scalar mean1=A[1,1] return scalar low1=A[5,1] return scalar up1=A[6,1] end *- step 2 模拟模块 clear set seed 11 simulate mean0=r(mean0) low0=r(low0) up0=r(up0) /// mean1=r(mean1) low1=r(low1) up1=r(up1), reps(100): model_1 //对model_1进行100次模拟,若有更换注意修改 gen id=_n *- step 3 模拟结果可视化 set scheme s1color //设定绘图模板 sum mean0 local b_mean `r(mean)' twoway (scatter mean0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat)") legend(order(1 "E(β{sub:x}_hat)点估计" 2 "E(β{sub:x}_hat)置信区间")) /// yline(`b_mean', lcolor(blue)) graph save model_1a.gph, replace //图名model_1a,若有更换注意修改 sum mean1 local b_mean `r(mean)' twoway (scatter mean1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat|z)") legend(order(1 "E(β{sub:x}_hat|z)点估计" 2 "E(β{sub:x}_hat|z)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_1b.gph, replace //图名model_1b,若有更换注意修改 graph combine model_1a.gph model_1b.gph , /// //若有更换注意修改图名 xsize(10) ysize(5) title("Model 1") //图形合并,图标题名Model 1,若有更换注意修改 ******************************************************************************** //model 2 ******************************************************************************** *- step 1 定义模型的数值模拟程序 *model 1 模拟程序 capture program drop model_2 //模型命名为model_1 program model_2,rclass clear set obs 10000 *************************** *model 2: DAG结构 gen u = rnormal() gen z = u + rnormal() gen x = z + rnormal() gen y = x + u + rnormal() *************************** *不控制z reg y x mat A=r(table) return scalar mean0=A[1,1] return scalar low0=A[5,1] return scalar up0=A[6,1] *控制z reg y x z mat A=r(table) return scalar mean1=A[1,1] return scalar low1=A[5,1] return scalar up1=A[6,1] end *- step 2 模拟模块 clear set seed 11 simulate mean0=r(mean0) low0=r(low0) up0=r(up0) /// mean1=r(mean1) low1=r(low1) up1=r(up1), reps(100): model_2 //若有更换注意修改 gen id=_n *- step 3 模拟结果可视化 set scheme s1color //设定绘图模板 sum mean0 local b_mean `r(mean)' twoway (scatter mean0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat)") legend(order(1 "E(β{sub:x}_hat)点估计" 2 "E(β{sub:x}_hat)置信区间")) /// yline(`b_mean', lcolor(blue)) graph save model_2a.gph, replace //若有更换注意修改 sum mean1 local b_mean `r(mean)' twoway (scatter mean1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat|z)") legend(order(1 "E(β{sub:x}_hat|z)点估计" 2 "E(β{sub:x}_hat|z)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_2b.gph, replace //若有更换注意修改 graph combine model_2a.gph model_2b.gph , /// //若有更换注意修改图名 xsize(10) ysize(5) title("Model 2") //若有更换注意修改 ******************************************************************************** //model 3 ******************************************************************************** *- step 1 定义模型的数值模拟程序 *model 1 模拟程序 capture program drop model_3 //若有更换注意修改 program model_3,rclass //若有更换注意修改 clear set obs 10000 *************************** *model 3: DAG结构 gen u = rnormal() gen z = u + rnormal() gen x = u + rnormal() gen y = x + z + rnormal() *************************** *不控制z reg y x mat A=r(table) return scalar mean0=A[1,1] return scalar low0=A[5,1] return scalar up0=A[6,1] *控制z reg y x z mat A=r(table) return scalar mean1=A[1,1] return scalar low1=A[5,1] return scalar up1=A[6,1] end *- step 2 模拟模块 clear set seed 11 simulate mean0=r(mean0) low0=r(low0) up0=r(up0) /// mean1=r(mean1) low1=r(low1) up1=r(up1), reps(100): model_3 //若有更换注意修改 gen id=_n *- step 3 模拟结果可视化 set scheme s1color //设定绘图模板 sum mean0 local b_mean `r(mean)' twoway (scatter mean0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat)") legend(order(1 "E(β{sub:x}_hat)点估计" 2 "E(β{sub:x}_hat)置信区间")) /// yline(`b_mean', lcolor(blue)) graph save model_3a.gph, replace //若有更换注意修改 sum mean1 local b_mean `r(mean)' twoway (scatter mean1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat|z)") legend(order(1 "E(β{sub:x}_hat|z)点估计" 2 "E(β{sub:x}_hat|z)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_3b.gph, replace //若有更换注意修改 graph combine model_3a.gph model_3b.gph , /// //若有更换注意修改图名 xsize(10) ysize(5) title("Model 3") //若有更换注意修改 ******************************************************************************** //model 4 ******************************************************************************** *- step 1 定义模型的数值模拟程序 *model 1 模拟程序 capture program drop model_4 //若有更换注意修改 program model_4,rclass //若有更换注意修改 clear set obs 10000 //若有更换注意修改 *************************** *model 4: DAG结构 gen z = rnormal() gen x = z + rnormal() gen m = x + z + rnormal() gen y = m + rnormal() *************************** *不控制z reg y x mat A=r(table) return scalar mean0=A[1,1] return scalar low0=A[5,1] return scalar up0=A[6,1] *控制z reg y x z mat A=r(table) return scalar mean1=A[1,1] return scalar low1=A[5,1] return scalar up1=A[6,1] end *- step 2 模拟模块 clear set seed 11 simulate mean0=r(mean0) low0=r(low0) up0=r(up0) /// mean1=r(mean1) low1=r(low1) up1=r(up1), reps(100): model_4 //若有更换注意修改 gen id=_n *- step 3 模拟结果可视化 set scheme s1color //设定绘图模板 sum mean0 local b_mean `r(mean)' twoway (scatter mean0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat)") legend(order(1 "E(β{sub:x}_hat)点估计" 2 "E(β{sub:x}_hat)置信区间")) /// yline(`b_mean', lcolor(blue)) graph save model_4a.gph, replace //若有更换注意修改 sum mean1 local b_mean `r(mean)' twoway (scatter mean1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat|z)") legend(order(1 "E(β{sub:x}_hat|z)点估计" 2 "E(β{sub:x}_hat|z)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_4b.gph, replace //若有更换注意修改 graph combine model_4a.gph model_4b.gph , /// //若有更换注意修改图名 xsize(10) ysize(5) title("Model 4") //若有更换注意修改 ******************************************************************************** //model 5 ******************************************************************************** *- step 1 定义模型的数值模拟程序 *model 1 模拟程序 capture program drop model_5 //若有更换注意修改 program model_5,rclass //若有更换注意修改 clear set obs 10000 //若有更换注意修改 *************************** *model 5: DAG结构 gen u = rnormal() gen z = u + rnormal() gen x = z + rnormal() gen m = x + u + rnormal() gen y = m + rnormal() *************************** *不控制z reg y x mat A=r(table) return scalar mean0=A[1,1] return scalar low0=A[5,1] return scalar up0=A[6,1] *控制z reg y x z mat A=r(table) return scalar mean1=A[1,1] return scalar low1=A[5,1] return scalar up1=A[6,1] end *- step 2 模拟模块 clear set seed 11 simulate mean0=r(mean0) low0=r(low0) up0=r(up0) /// mean1=r(mean1) low1=r(low1) up1=r(up1), reps(100): model_5 //若有更换注意修改 gen id=_n *- step 3 模拟结果可视化 set scheme s1color //设定绘图模板 sum mean0 local b_mean `r(mean)' twoway (scatter mean0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat)") legend(order(1 "E(β{sub:x}_hat)点估计" 2 "E(β{sub:x}_hat)置信区间")) /// yline(`b_mean', lcolor(blue)) graph save model_5a.gph, replace //若有更换注意修改 sum mean1 local b_mean `r(mean)' twoway (scatter mean1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat|z)") legend(order(1 "E(β{sub:x}_hat|z)点估计" 2 "E(β{sub:x}_hat|z)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_5b.gph, replace //若有更换注意修改 graph combine model_5a.gph model_5b.gph , /// //若有更换注意修改图名 xsize(10) ysize(5) title("Model 5") //若有更换注意修改 ******************************************************************************** //model 6 ******************************************************************************** *- step 1 定义模型的数值模拟程序 *model 1 模拟程序 capture program drop model_6 //若有更换注意修改 program model_6,rclass //若有更换注意修改 clear set obs 10000 //若有更换注意修改 *************************** *model 6: DAG结构 gen u = rnormal() gen z = u + rnormal() gen x = u + rnormal() gen m = x + z + rnormal() gen y = m + rnormal() *************************** *不控制z reg y x mat A=r(table) return scalar mean0=A[1,1] return scalar low0=A[5,1] return scalar up0=A[6,1] *控制z reg y x z mat A=r(table) return scalar mean1=A[1,1] return scalar low1=A[5,1] return scalar up1=A[6,1] end *- step 2 模拟模块 clear set seed 11 simulate mean0=r(mean0) low0=r(low0) up0=r(up0) /// mean1=r(mean1) low1=r(low1) up1=r(up1), reps(100): model_6 //若有更换注意修改 gen id=_n *- step 3 模拟结果可视化 set scheme s1color //设定绘图模板 sum mean0 local b_mean `r(mean)' twoway (scatter mean0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat)") legend(order(1 "E(β{sub:x}_hat)点估计" 2 "E(β{sub:x}_hat)置信区间")) /// yline(`b_mean', lcolor(blue)) graph save model_6a.gph, replace //若有更换注意修改 sum mean1 local b_mean `r(mean)' twoway (scatter mean1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat|z)") legend(order(1 "E(β{sub:x}_hat|z)点估计" 2 "E(β{sub:x}_hat|z)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_6b.gph, replace //若有更换注意修改 graph combine model_6a.gph model_6b.gph , /// //若有更换注意修改图名 xsize(10) ysize(5) title("Model 6") //若有更换注意修改 ******************************************************************************** //model 15 ******************************************************************************** *- step 1 定义模型的数值模拟程序 *model 15 模拟程序 capture program drop model_15 //若有更换注意修改 program model_15,rclass //若有更换注意修改 clear set obs 10000 //若有更换注意修改 *************************** *model 15: DAG结构 gen x = rnormal() gen u = rnormal() gen z = x + rnormal() gen w = z + u + rnormal() gen y = x -2*u + rnormal() *************************** *控制w,不控制z reg y x w mat A=r(table) return scalar mean0=A[1,1] return scalar low0=A[5,1] return scalar up0=A[6,1] *控制w和z reg y x w z mat A=r(table) return scalar mean1=A[1,1] return scalar low1=A[5,1] return scalar up1=A[6,1] end *- step 2 模拟模块 clear set seed 11 simulate mean0=r(mean0) low0=r(low0) up0=r(up0) /// mean1=r(mean1) low1=r(low1) up1=r(up1), reps(100): model_15 //若有更换注意修改 gen id=_n *- step 3 模拟结果可视化 set scheme s1color //设定绘图模板 sum mean0 local b_mean `r(mean)' twoway (scatter mean0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat)") legend(order(1 "E(β{sub:x}_hat|w)点估计" 2 "E(β{sub:x}_hat|w)置信区间")) /// yline(`b_mean', lcolor(blue)) graph save model_15a.gph, replace //若有更换注意修改 sum mean1 local b_mean `r(mean)' twoway (scatter mean1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat|z)") legend(order(1 "E(β{sub:x}_hat|w z)点估计" 2 "E(β{sub:x}_hat|w z)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_15b.gph, replace //若有更换注意修改 graph combine model_15a.gph model_15b.gph , /// //若有更换注意修改图名 xsize(10) ysize(5) title("Model 15") //若有更换注意修改 ******************************************************************************** //model 7 ******************************************************************************** *- step 1 定义模型的数值模拟程序 *model 7 模拟程序 capture program drop model_7 //若有更换注意修改 program model_7,rclass //若有更换注意修改 clear set obs 10000 //若有更换注意修改 *************************** *model 7: DAG结构 gen u1 = rnormal() gen u2 = rnormal() gen z = u1 + u2 + rnormal() gen x = u1 + rnormal() gen y = x -4*u2 + rnormal() *************************** *不控制z reg y x mat A=r(table) return scalar mean0=A[1,1] return scalar low0=A[5,1] return scalar up0=A[6,1] *控制z reg y x z mat A=r(table) return scalar mean1=A[1,1] return scalar low1=A[5,1] return scalar up1=A[6,1] end *- step 2 模拟模块 clear set seed 11 simulate mean0=r(mean0) low0=r(low0) up0=r(up0) /// mean1=r(mean1) low1=r(low1) up1=r(up1), reps(100): model_7 //若有更换注意修改 gen id=_n *- step 3 模拟结果可视化 set scheme s1color //设定绘图模板 sum mean0 local b_mean `r(mean)' twoway (scatter mean0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat)") legend(order(1 "E(β{sub:x}_hat)点估计" 2 "E(β{sub:x}_hat)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_7a.gph, replace //若有更换注意修改 sum mean1 local b_mean `r(mean)' twoway (scatter mean1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat|z)") legend(order(1 "E(β{sub:x}_hat|z)点估计" 2 "E(β{sub:x}_hat|z)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_7b.gph, replace //若有更换注意修改 graph combine model_7a.gph model_7b.gph , /// //若有更换注意修改图名 xsize(10) ysize(5) title("Model 7") //若有更换注意修改 ******************************************************************************** //model 10 ******************************************************************************** *- step 1 定义模型的数值模拟程序 *model 10 模拟程序 capture program drop model_10 //若有更换注意修改 program model_10,rclass //若有更换注意修改 clear set obs 10000 //若有更换注意修改 *************************** *model 10: DAG结构 gen z = rnormal() gen u = rnormal() gen x = -2*z + u + rnormal() gen y = x + 2*u + rnormal() *************************** *不控制z reg y x mat A=r(table) return scalar mean0=A[1,1] return scalar low0=A[5,1] return scalar up0=A[6,1] *控制z reg y x z mat A=r(table) return scalar mean1=A[1,1] return scalar low1=A[5,1] return scalar up1=A[6,1] end *- step 2 模拟模块 clear set seed 11 simulate mean0=r(mean0) low0=r(low0) up0=r(up0) /// mean1=r(mean1) low1=r(low1) up1=r(up1), reps(100): model_10 //若有更换注意修改 gen id=_n *- step 3 模拟结果可视化 set scheme s1color //设定绘图模板 sum mean0 local b_mean `r(mean)' twoway (scatter mean0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat)") legend(order(1 "E(β{sub:x}_hat)点估计" 2 "E(β{sub:x}_hat)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_10a.gph, replace //若有更换注意修改 sum mean1 local b_mean `r(mean)' twoway (scatter mean1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat|z)") legend(order(1 "E(β{sub:x}_hat|z)点估计" 2 "E(β{sub:x}_hat|z)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_10b.gph, replace //若有更换注意修改 graph combine model_10a.gph model_10b.gph , /// //若有更换注意修改图名 xsize(10) ysize(5) title("Model 10") //若有更换注意修改 ******************************************************************************** //model 11 ******************************************************************************** *- step 1 定义模型的数值模拟程序 *model 11 模拟程序 capture program drop model_11 //若有更换注意修改 program model_11,rclass //若有更换注意修改 clear set obs 10000 //若有更换注意修改 *************************** *model 11: DAG结构 gen x = rnormal() gen z = x + rnormal() gen y = z + rnormal() *************************** *不控制z reg y x mat A=r(table) return scalar mean0=A[1,1] return scalar low0=A[5,1] return scalar up0=A[6,1] *控制z reg y x z mat A=r(table) return scalar mean1=A[1,1] return scalar low1=A[5,1] return scalar up1=A[6,1] end *- step 2 模拟模块 clear set seed 11 simulate mean0=r(mean0) low0=r(low0) up0=r(up0) /// mean1=r(mean1) low1=r(low1) up1=r(up1), reps(100): model_11 //若有更换注意修改 gen id=_n *- step 3 模拟结果可视化 set scheme s1color //设定绘图模板 sum mean0 local b_mean `r(mean)' twoway (scatter mean0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat)") legend(order(1 "E(β{sub:x}_hat)点估计" 2 "E(β{sub:x}_hat)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_11a.gph, replace //若有更换注意修改 sum mean1 local b_mean `r(mean)' twoway (scatter mean1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat|z)") legend(order(1 "E(β{sub:x}_hat|z)点估计" 2 "E(β{sub:x}_hat|z)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_11b.gph, replace //若有更换注意修改 graph combine model_11a.gph model_11b.gph , /// //若有更换注意修改图名 xsize(10) ysize(5) title("Model 11") //若有更换注意修改 ******************************************************************************** //model 12 ******************************************************************************** *- step 1 定义模型的数值模拟程序 *model 12 模拟程序 capture program drop model_12 //若有更换注意修改 program model_12,rclass //若有更换注意修改 clear set obs 10000 //若有更换注意修改 *************************** *model 12: DAG结构 gen x = rnormal() gen m = x + rnormal() gen z = m + rnormal() gen y = m + rnormal() *************************** *不控制z reg y x mat A=r(table) return scalar mean0=A[1,1] return scalar low0=A[5,1] return scalar up0=A[6,1] *控制z reg y x z mat A=r(table) return scalar mean1=A[1,1] return scalar low1=A[5,1] return scalar up1=A[6,1] end *- step 2 模拟模块 clear set seed 11 simulate mean0=r(mean0) low0=r(low0) up0=r(up0) /// mean1=r(mean1) low1=r(low1) up1=r(up1), reps(100): model_12 //若有更换注意修改 gen id=_n *- step 3 模拟结果可视化 set scheme s1color //设定绘图模板 sum mean0 local b_mean `r(mean)' twoway (scatter mean0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat)") legend(order(1 "E(β{sub:x}_hat)点估计" 2 "E(β{sub:x}_hat)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_12a.gph, replace //若有更换注意修改 sum mean1 local b_mean `r(mean)' twoway (scatter mean1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat|z)") legend(order(1 "E(β{sub:x}_hat|z)点估计" 2 "E(β{sub:x}_hat|z)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_12b.gph, replace //若有更换注意修改 graph combine model_12a.gph model_12b.gph , /// //若有更换注意修改图名 xsize(10) ysize(5) title("Model 12") //若有更换注意修改 ******************************************************************************** //model 16 ******************************************************************************** *- step 1 定义模型的数值模拟程序 *model 16 模拟程序 capture program drop model_16 //若有更换注意修改 program model_16,rclass //若有更换注意修改 clear set obs 10000 //若有更换注意修改 *************************** *model 16: DAG结构 gen x = rnormal() gen u = rnormal() gen z = x + u + rnormal() gen y = x + 2*u + rnormal() *************************** *不控制z reg y x mat A=r(table) return scalar mean0=A[1,1] return scalar low0=A[5,1] return scalar up0=A[6,1] *控制z reg y x z mat A=r(table) return scalar mean1=A[1,1] return scalar low1=A[5,1] return scalar up1=A[6,1] end *- step 2 模拟模块 clear set seed 11 simulate mean0=r(mean0) low0=r(low0) up0=r(up0) /// mean1=r(mean1) low1=r(low1) up1=r(up1), reps(100): model_16 //若有更换注意修改 gen id=_n *- step 3 模拟结果可视化 set scheme s1color //设定绘图模板 sum mean0 local b_mean `r(mean)' twoway (scatter mean0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat)") legend(order(1 "E(β{sub:x}_hat)点估计" 2 "E(β{sub:x}_hat)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_16a.gph, replace //若有更换注意修改 sum mean1 local b_mean `r(mean)' twoway (scatter mean1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat|z)") legend(order(1 "E(β{sub:x}_hat|z)点估计" 2 "E(β{sub:x}_hat|z)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_16b.gph, replace //若有更换注意修改 graph combine model_16a.gph model_16b.gph , /// //若有更换注意修改图名 xsize(10) ysize(5) title("Model 16") //若有更换注意修改 ******************************************************************************** //model 17 ******************************************************************************** *- step 1 定义模型的数值模拟程序 *model 17 模拟程序 capture program drop model_17 //若有更换注意修改 program model_17,rclass //若有更换注意修改 clear set obs 10000 //若有更换注意修改 *************************** *model 17: DAG结构 gen x = rnormal() gen y = x + rnormal() gen z = x + y + rnormal() *************************** *不控制z reg y x mat A=r(table) return scalar mean0=A[1,1] return scalar low0=A[5,1] return scalar up0=A[6,1] *控制z reg y x z mat A=r(table) return scalar mean1=A[1,1] return scalar low1=A[5,1] return scalar up1=A[6,1] end *- step 2 模拟模块 clear set seed 11 simulate mean0=r(mean0) low0=r(low0) up0=r(up0) /// mean1=r(mean1) low1=r(low1) up1=r(up1), reps(100): model_17 //若有更换注意修改 gen id=_n *- step 3 模拟结果可视化 set scheme s1color //设定绘图模板 sum mean0 local b_mean `r(mean)' twoway (scatter mean0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat)") legend(order(1 "E(β{sub:x}_hat)点估计" 2 "E(β{sub:x}_hat)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_17a.gph, replace //若有更换注意修改 sum mean1 local b_mean `r(mean)' twoway (scatter mean1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat|z)") legend(order(1 "E(β{sub:x}_hat|z)点估计" 2 "E(β{sub:x}_hat|z)置信区间")) /// yline(`b_mean', lcolor(blue)) graph save model_17b.gph, replace //若有更换注意修改 graph combine model_17a.gph model_17b.gph , /// //若有更换注意修改图名 xsize(10) ysize(5) title("Model 17") //若有更换注意修改 ******************************************************************************** //model 18 ******************************************************************************** *- step 1 定义模型的数值模拟程序 *model 18 模拟程序 capture program drop model_18 //若有更换注意修改 program model_18,rclass //若有更换注意修改 clear set obs 10000 //若有更换注意修改 *************************** *model 18: DAG结构 gen x = rnormal() gen y = x + rnormal() gen z = y + rnormal() *************************** *不控制z reg y x mat A=r(table) return scalar mean0=A[1,1] return scalar low0=A[5,1] return scalar up0=A[6,1] *控制z reg y x z mat A=r(table) return scalar mean1=A[1,1] return scalar low1=A[5,1] return scalar up1=A[6,1] end *- step 2 模拟模块 clear set seed 11 simulate mean0=r(mean0) low0=r(low0) up0=r(up0) /// mean1=r(mean1) low1=r(low1) up1=r(up1), reps(100): model_18 //若有更换注意修改 gen id=_n *- step 3 模拟结果可视化 set scheme s1color //设定绘图模板 sum mean0 local b_mean `r(mean)' twoway (scatter mean0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat)") legend(order(1 "E(β{sub:x}_hat)点估计" 2 "E(β{sub:x}_hat)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_18a.gph, replace //若有更换注意修改 sum mean1 local b_mean `r(mean)' twoway (scatter mean1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat|z)") legend(order(1 "E(β{sub:x}_hat|z)点估计" 2 "E(β{sub:x}_hat|z)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_18b.gph, replace //若有更换注意修改 graph combine model_18a.gph model_18b.gph , /// //若有更换注意修改图名 xsize(10) ysize(5) title("Model 18") //若有更换注意修改 ******************************************************************************** //model 8 ******************************************************************************** *- step 1 定义模型的数值模拟程序 *model 8 模拟程序 capture program drop model_8 //若有更换注意修改 program model_8,rclass //若有更换注意修改 clear set obs 10000 //若有更换注意修改 *************************** *model 8: DAG结构 gen z = rnormal() gen x = rnormal() gen y = x + 2*z + rnormal() *************************** *不控制z reg y x mat A=r(table) return scalar mean0=A[1,1] return scalar low0=A[5,1] return scalar up0=A[6,1] *控制z reg y x z mat A=r(table) return scalar mean1=A[1,1] return scalar low1=A[5,1] return scalar up1=A[6,1] end *- step 2 模拟模块 clear set seed 11 simulate mean0=r(mean0) low0=r(low0) up0=r(up0) /// mean1=r(mean1) low1=r(low1) up1=r(up1), reps(100): model_8 //若有更换注意修改 gen id=_n *- step 3 模拟结果可视化 set scheme s1color //设定绘图模板 sum mean0 local b_mean `r(mean)' twoway (scatter mean0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat)") legend(order(1 "E(β{sub:x}_hat)点估计" 2 "E(β{sub:x}_hat)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_8a.gph, replace //若有更换注意修改 sum mean1 local b_mean `r(mean)' twoway (scatter mean1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat|z)") legend(order(1 "E(β{sub:x}_hat|z)点估计" 2 "E(β{sub:x}_hat|z)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_8b.gph, replace //若有更换注意修改 graph combine model_8a.gph model_8b.gph , /// //若有更换注意修改图名 xsize(10) ysize(5) title("Model 8") //若有更换注意修改 ******************************************************************************** //model 13 ******************************************************************************** *- step 1 定义模型的数值模拟程序 *model 13 模拟程序 capture program drop model_13 //若有更换注意修改 program model_13,rclass //若有更换注意修改 clear set obs 10000 //若有更换注意修改 *************************** *model 13: DAG结构 gen z = rnormal() gen x = rnormal() gen m = 2*z + rnormal() gen y = x + 2*m + rnormal() *************************** *不控制z reg y x mat A=r(table) return scalar mean0=A[1,1] return scalar low0=A[5,1] return scalar up0=A[6,1] *控制z reg y x z mat A=r(table) return scalar mean1=A[1,1] return scalar low1=A[5,1] return scalar up1=A[6,1] end *- step 2 模拟模块 clear set seed 11 simulate mean0=r(mean0) low0=r(low0) up0=r(up0) /// mean1=r(mean1) low1=r(low1) up1=r(up1), reps(100): model_13 //若有更换注意修改 gen id=_n *- step 3 模拟结果可视化 set scheme s1color //设定绘图模板 sum mean0 local b_mean `r(mean)' twoway (scatter mean0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat)") legend(order(1 "E(β{sub:x}_hat)点估计" 2 "E(β{sub:x}_hat)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_13a.gph, replace //若有更换注意修改 sum mean1 local b_mean `r(mean)' twoway (scatter mean1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat|z)") legend(order(1 "E(β{sub:x}_hat|z)点估计" 2 "E(β{sub:x}_hat|z)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_13b.gph, replace //若有更换注意修改 graph combine model_13a.gph model_13b.gph , /// //若有更换注意修改图名 xsize(10) ysize(5) title("Model 13") //若有更换注意修改 ******************************************************************************** //model 9 ******************************************************************************** *- step 1 定义模型的数值模拟程序 *model 9 模拟程序 capture program drop model_9 //若有更换注意修改 program model_9,rclass //若有更换注意修改 clear set obs 10000 //若有更换注意修改 *************************** *model 9: DAG结构 gen z = rnormal() gen x = 2*z + rnormal() gen y = x + 2*rnormal() *************************** *不控制z reg y x mat A=r(table) return scalar mean0=A[1,1] return scalar low0=A[5,1] return scalar up0=A[6,1] *控制z reg y x z mat A=r(table) return scalar mean1=A[1,1] return scalar low1=A[5,1] return scalar up1=A[6,1] end *- step 2 模拟模块 clear set seed 11 simulate mean0=r(mean0) low0=r(low0) up0=r(up0) /// mean1=r(mean1) low1=r(low1) up1=r(up1), reps(100): model_9 //若有更换注意修改 gen id=_n *- step 3 模拟结果可视化 set scheme s1color //设定绘图模板 sum mean0 local b_mean `r(mean)' twoway (scatter mean0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat)") legend(order(1 "E(β{sub:x}_hat)点估计" 2 "E(β{sub:x}_hat)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_9a.gph, replace //若有更换注意修改 sum mean1 local b_mean `r(mean)' twoway (scatter mean1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat|z)") legend(order(1 "E(β{sub:x}_hat|z)点估计" 2 "E(β{sub:x}_hat|z)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_9b.gph, replace //若有更换注意修改 graph combine model_9a.gph model_9b.gph , /// //若有更换注意修改图名 xsize(10) ysize(5) title("Model 9") //若有更换注意修改 ******************************************************************************** //model 14 ******************************************************************************** *- step 1 定义模型的数值模拟程序 *model 14 模拟程序 capture program drop model_14 //若有更换注意修改 program model_14,rclass //若有更换注意修改 clear set obs 10000 //若有更换注意修改 *************************** *model 14: DAG结构 gen x = rnormal() gen z = 2*x + rnormal() gen y = x + 2*rnormal() *************************** *不控制z reg y x mat A=r(table) return scalar mean0=A[1,1] return scalar low0=A[5,1] return scalar up0=A[6,1] *控制z reg y x z mat A=r(table) return scalar mean1=A[1,1] return scalar low1=A[5,1] return scalar up1=A[6,1] end *- step 2 模拟模块 clear set seed 11 simulate mean0=r(mean0) low0=r(low0) up0=r(up0) /// mean1=r(mean1) low1=r(low1) up1=r(up1), reps(100): model_14 //若有更换注意修改 gen id=_n *- step 3 模拟结果可视化 set scheme s1color //设定绘图模板 sum mean0 local b_mean `r(mean)' twoway (scatter mean0 id, ms(Oh) mc(gs5)) (rcap low0 up0 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat)") legend(order(1 "E(β{sub:x}_hat)点估计" 2 "E(β{sub:x}_hat)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_14a.gph, replace //若有更换注意修改 sum mean1 local b_mean `r(mean)' twoway (scatter mean1 id, ms(Oh) mc(gs5)) (rcap low1 up1 id, lc(gs5)), /// ytitle("E(β{sub:x}_hat|z)") legend(order(1 "E(β{sub:x}_hat|z)点估计" 2 "E(β{sub:x}_hat|z)置信区间")) /// yline(`b_mean', lcolor(blue)) yline(1, lcolor(red)) graph save model_14b.gph, replace //若有更换注意修改 graph combine model_14a.gph model_14b.gph , /// //若有更换注意修改图名 xsize(10) ysize(5) title("Model 14") //若有更换注意修改