Search code examples
plotstata

Plotting coefficients in Stata


I followed

https://www.stata.com/meeting/germany14/abstracts/materials/de14_jann.pdf

to plot coefficients of age.

I did

logit Y i.age
eststo plotplot
coefplot plotplot

But the plot has age on vertical axis, and coefficient on horizontal axis. It should be the opposite.

Also, I only want the coefficients of age, not constant or anything else. How do I do that?

And does "at" command work for discretized explanatory variable like i.age ? Or is it the case that it just takes so much time (I had to stop it because it was taking so much time)?


Solution

  • The logit coefficients are not particularly interpretable, so it is not clear why you want to plot them. There is also no at command, though the margins command has an at() option. If you do want the index function coefficients, just omit the margins step from below. coefplot and marginsplot do very similar things, though coefplot is considerably more flexible.

    I am guessing you have something in mind like this:

    sysuse auto, clear
    xtile mpg_tercile = mpg, nq(3)
    logit foreign i.mpg_tercile weight
    margins, dydx(mpg_tercile) at(weight = 3000) post
    coefplot, vertical
    marginsplot, recast(scatter)
    

    This calculates the average marginal effect of falling in the middle or top third of the mile per gallon distribution on the probability of the car being foreign with weight of 3000.