I have a GLM model, which I estimate in Stata. The coefficients of interest are the marginal effects, which I get with margins
command.
However, the postestimation table does not include summary statistics like AIC, which I would like to have there.
I have tried this by writing an auxiliary program getAIC
:
program getAIC
estat ic
matrix list r(S)
matrix S = r(S)
scalar aic = S[1,5]
end
The estimation would then proceed like this:
qui glm y x, fa(bin) link(probit)
getAIC
qui margins, dydx(x) post
estadd loc AIC aic
And the output command is:
esttab using output.tex, s(aic, fmt(0))
However, I don't have AIC in the results table.
Any ideas how to do this?
You need to return the scalar
aic
from your programgetAIC
and use it accordingly.The following works for me: