I am using estout from SSC in Stata 17.0 on Windows 10. My goal is to fit a multi-level model using melogit and print the estimates using esttab. I want the table to show numbers of distinct grouping levels (parties and countries), so I wrote the following command:
Code:
melogit Y x1 x2 x3 || country: || party: est store model1 esttab model1 label nodep style(tex) nomtitles /// cells(b(star fmt(a1)) se(fmt(a1) par)) replace star(* 0.10 ** 0.05 *** 0.01) stats(N N_g)
According to the melogit`s documentation, it stores N_g as a matrix. But the esttab manual indicates that stats() option only accepts scalars. So I modified the code as follows:
Code:
melogit Y x1 x2 x3 || country: || party: est store model1 matrix N_g = e(N_g) estadd scalar N_party = N_g[1,2] estadd scalar N_country = N_g[1,1] esttab model1 label nodep style(tex) nomtitles cells(b(star fmt(a1)) se(fmt(a1) par)) /// replace star(* 0.10 ** 0.05 *** 0.01) stats(N N_party N_country)
My questions are:
- Is there a more elegant way to do this? Since my code would be applied to many different models, adding a few lines after each model fitting could make the project quite messy.
- Is it possible to store all N_g values in a separate variables like a varlist, and then use them as input to stats()? Or does esttab only accept values added with estadd?
0 Response to How to print numbers of levels in melogit models using esttab?
Post a Comment