capture log close log using cace, replace set more off ** CACE model in gllamm * Data preparation infile depress risk r depbase age motivate educ /* */ assert single econ nonwhite x10 c c0 using wjobs.dat, clear gen y1 = c if r==1 /* compliance missing in control group */ gen y2 = depress gen id=_n reshape long y, i(id) j(var) tab var, gen(d) /* create dummies d1 and d2 */ * List some data drop if y==. list id var d1 d2 y r c if id==1 | id==2 | id==175 | id==176, clean ** CACE model in gllamm (cont'd) * Interactions and equations gen nr_d2 = (1-r)*d2 gen c_r_d2 = c*r*d2 eq load: nr_d2 /* for beta_1(1-r_j)d_2i */ * Constraints cons def 1 [p2_1]_cons = [y]d1 /* constraint for varrho */ cons def 2 [z2_1_1]nr_d2 = 1 /* e_1 = 1 */ cons def 3 [z2_1_2]nr_d2 = 0 /* e_2 = 0 */ * gllamm command gllamm y d1 d2 c_r_d2, i(id) eqs(load) l(logit ident) /* */ f(binom gauss) lv(var) fv(var) ip(fn) nip(2) /* */ constr(1/3) frload(1) nocons /* beta_1 is "freed" by frload(1) */ ** Estimates * CACE lincom [y]c_r_d2 - [id1_1l]nr_d2 ** Add predictors of compliance * Make interactions with d1 (dummy for compliance) gen age_d1 = age*d1 gen motivate_d1 = motivate*d1 gen educ_d1 = educ*d1 gen assert_d1 = assert*d1 gen single_d1 = single*d1 gen econ_d1 = econ*d1 gen nonwhite_d1 = nonwhite*d1 ** Add predictors of depression with constant effects across compliance groups * make interactions with d2 (dummy for depression) gen depbase_d2 = depbase*d2 gen risk_d2 = risk*d2 * New constraints cons def 4 [p2_1]age = [y]age_d1 cons def 5 [p2_1]motivate = [y]motivate_d1 cons def 6 [p2_1]educ = [y]educ_d1 cons def 7 [p2_1]assert = [y]assert_d1 cons def 8 [p2_1]single = [y]single_d1 cons def 9 [p2_1]econ = [y]econ_d1 cons def 10 [p2_1]nonwhite = [y]nonwhite_d1 ** Estimate model eq p: age educ motivate econ assert single nonwhite eq load: nr_d2 gllamm y d1 age_d1 educ_d1 motivate_d1 econ_d1 assert_d1 single_d1 nonwhite_d1 /* */ d2 c_r_d2 depbase_d2 risk_d2, i(id) eqs(load) /* */ peqs(p) l(logit ident) f(binom gauss) lv(var) fv(var) ip(fn) nip(2) /* */ constr(1/10) frload(1) nocons ** Complier Average Causal Effect lincom [y]c_r_d2 - [id1_1l]nr_d2 log close exit