Reputation: 1293
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?
Upvotes: 0
Views: 282
Reputation:
You need to return the scalar aic
from your program getAIC
and use it accordingly.
The following works for me:
program getAIC, rclass
estat ic
matrix list r(S)
matrix S = r(S)
scalar aic = S[1,5]
return scalar aic = aic
end
sysuse auto, clear
glm foreign price, fa(bin) link(probit)
getAIC
local AIC = round(`r(aic)', .01)
margins, dydx(price) post
estadd local AIC `AIC'
esttab using output, s(AIC) replace
type output.txt
----------------------------
(1)
----------------------------
price 0.00000766
(0.43)
----------------------------
AIC 93.89
----------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001
Upvotes: 2