clear tempname match tempfile match_out postfile `match' str12(method) true_effect est_effect using match_out, replace local i 1 quietly while `i' < 201 { clear drawnorm x1 x2 u, n(500) drawnorm e1 e0, corr(1, .25\.25, 1) local g 1 local r 1 gen y1 = 5 + 2*x1 - 2*x2 + e1 gen y0 = 2 + x1 - x2 + e0 gen tstar = -1.5 + `g'*x1 + `g'*`r'*(-1)*x2 + u gen true_prop = normal(tstar-u) gen t = tstar > 0 tab t gen y = y1*(t) + y0*(1-t) corr tstar x1 x2 y1 y0 gen t_effect = (y1-y0) - (e1-e0) bysort t: sum t_effect true_prop y1 y0 e1 e0 tstar sum t_effect if t == 1 local true_effect = r(mean) reg y t x1 x2 post `match' ("OLS") (`true_effect') (_b[t]) gen goff = uniform() sort goff psmatch2 t, pscore(true_prop) outcome(y) noreplacement post `match' ("TRUE PSCORE") (`true_effect') (r(att)) *Estimate propensity score model) probit t x1 x2 matrix m = (_b[x1]^2, 0 \0,_b[x2]^2) psmatch2 t, outcome(y) mahalanobis(x1 x2) w(`m') post `match' ("COV&PROP") (`true_effect') (r(att)) local i = `i' + 1 } postclose `match' use match_out, clear collapse (mean) mean_effect = est_effect mean_true = true_effect (sd) sd_effect = est_effect , by(method) gen var = sd_effect^2 gen bias = mean_effect - mean_true gen mse = bias^2 + var