In order to save time and make my do-file shorter and clearer, I'd like to run a loop that would include a list of nested models, generating marginal effects and storing them after each model.The final goal is to save the subsequent table in an Excel file.
The list of models and coding is as follows:
PHP Code:
mlogit vardep X1, baseoutcome(2)
estpost margins, dydx(*) predict(outcome(2))
estimates store m1, title (Model 1)
mlogit vardep X1 X2, baseoutcome(2)
estpost margins, dydx(*) predict(outcome(Other_studies))
estimates store m2, title (Model 2)
mlogit vardep X1 X2 X3, baseoutcome(2)
estpost margins, dydx(*) predict(outcome(Other_studies))
estimates store m3, title (Model 3)
mlogit vardep X1 X2 X3 X4, baseoutcome(2)
estpost margins, dydx(*) predict(outcome(Other_studies))
estimates store m4, title (Model 4)
mlogit vardep X1 X2 X3 X4 X5, baseoutcome(2)
estpost margins, dydx(*) predict(outcome(Other_studies))
estimates store m5, title (Model 5)
esttab m1 m2 m3 m4 m5 using "[PATH]...\Expectativas_ocuma1.csv", ///
cells(b(star fmt(3)) se(par fmt(2))) legend label varlabels(_cons Constant) stats(r2) nobaselevels unstack noomitted replace
It is easy to see that the lines after each model are common to all the models.Thus, it should be easy to make a loop summarising all this coding. But I do not know how to include the different models in the loop. Shall I use foreach, or different globals capturing each one the list of variables in each model?
Thanks for your attention
Kind regards
Luis Ortiz
0 Response to Running a loop with nested multinomial logit models
Post a Comment