- https://www.statalist.org/forums/for...sion-in-a-loop
- https://www.statalist.org/forums/for...s-from-margins
HTML Code:
************************************************* * Load Panel Data ************************************************* webuse nlswork, clear xtset idcode ************************************************* * Loop for different outcomes local outcomes "ln_wage hours wks_work" foreach o of local outcomes { quietly xtreg `o' age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure c.tenure#c.tenure, fe estimates store reg_`o' } estimates table reg_ln_wage reg_hours reg_wks_work ************************************************* ************************************************* * Loop regressions and save marginal effects (difficult due to matrix object) local outcomes "ln_wage hours wks_work" foreach o of local outcomes { quietly xtreg `o' age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure c.tenure#c.tenure, fe margins, dydx(age) matrix B`o' = r(b) } * to be continued *************************************************
0 Response to Storing marginal effects in a loop of regressions
Post a Comment