Seems that my students and I are not the only ones who are occasionally baffled by Stata’s margins command, which does all sorts of amazing things. Margins is incredibly powerful, and the accompanying marginsplot command almost always does just the right thing. These commands come with excellent documentation, but at a mere 58 pages (not counting the remarks on margins post-estimation), the manual entry on margins alone is a little overwhelming, and there are just too many options.
There are two separate issues in particular that seem to confuse a lot of people (see this discussion on statalist on the then new margins command).
Marginal Effects at the Mean vs Average Marginal Effects
The first is that in the past when studying the implications from nonlinear (i.e. logit) models, many people including me used to analyse “marginal effects at the mean“. In short, this boils down to holding most independent variables constant at their grand means/modes while plugging a range of hopefully relevant values for one or two focal variables into the equation. This approach, which was pioneered by J. Scott Long, is easier to understand than to explain and greatly aids the interpretation of non-linear models.
Margins can (amongst many other things) estimate marginal effects at the mean. But unfortunately, this can result in very unrealistic scenarios if your independent variables are highly correlated (think of holding age constant at its mean while varying pensioner/non-pensioner status).
Therefore, looking at “average marginal effects” often makes more sense. These are calculated by varying the focal variable while holding everything else at their variables. This is was the margins command does by default. Michael Norman Mitchell has a post (since removed, but thankfully preserved by the internet archive) that clearly illustrates the differences between the two approaches to the estimation of margins. If you are ready for a somewhat deeper dive, Richard Williams’ 2012 article on Using the margins command to estimate and interpret adjusted predictions and marginal effects is a modern classic and a masterclass in didactics, free for you to read at this URL. Moreover, there is an older article by Tamás Bartus on his margeff command that is also quite instructive.
One problem with understanding what margins (the thing) and margins (the command) are about is that the terminology varies wildly within and across disciplines. In this respect, I find Williams’ definitions and explanations particularly helpful.
Dubious Confidence Intervals
But one problem remains: margins uses a normal approximation for calculating confidence intervals. As a result, after estimating a model for categorical dependent variables, you might end up with a CI for your margins that includes zero, which obviously does not make much sense. Roger Newson seems to know how to get around this issue. So far, I haven’t used his approach, but it looks plausible enough.
Margins and the marginsplot command are incredibly powerful tools. I take it that they have been partially ported to R, but I do not know if these packages are as good as the original. My students have been conditioned (geddit? geddit) to resort with margins whenever we encounter interactions and nonlinearities. If you want to get an idea what margins can do for you, there is a lot of tutorials on the internet to work through, and the Stata blog is not the worst place to start.
11 thoughts on “ME at the Margins: Average Marginal Effects, Marginal Effects at the Mean, and Stata’s margins command”
Vaya, ya te hicieron visible – parecía que Elon Musk te hubiese enviado en un SpaceX a Marte.😀
Hey Kai, looks like the Facebook SocialSync is working great on your site! 🙂 Very happy to see that! Pumped to have you using Livefyre. Welcome to the community!
Thanks Ben – very useful indeed
I’ve found this http://www.nd.edu/~rwilliam/xsoc73994/Margins01.pdf and this http://www.nd.edu/~rwilliam/xsoc73994/Margins02.pdf pretty useful.