UCLA IDRE: How Can I Graph the Results of the Margins Command
- Due No Due Date
- Points 0
Stata's margins command is very powerful and offers an excellent way for interpreting model output - but it's even better when used to create graphical summaries.
However, sometimes it's not entirely clear what margins is giving you or how to get what you want back. Stata's built in marginsplot command can be a bit restrictive. In this FAQ from UCLA IDRE Statistical Consulting there are several helpful examples of margins used after common estimation techniques. You'll see how to compute margins at values of interest and how to store those results as matrices that allow for more flexible plotting.
If the above seems too difficult or confusing, or if you're more comfortable with Stata's dropdown menus than syntax, try these two youtube playlists by Chuck Huber that cover margins and marginsplots (syntax is compatible with Stata 12 and newer but menus may look different in your version):
- Using margins in Stata Links to an external site.
- Profile plots and interaction plots in Stata Links to an external site.
Getting what you want but it's not pretty? For help making graphs pretty as in Andrew's examples, see Ben Jann's grstyle. Links to an external site.Then, to put it all together, here's a nice example with marginsplot from Andrew Wheeler Links to an external site. that walks through how to plot results of a logit model with an interaction term and apply grstyle.