Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Marginsplot: Connecting margins in non-default order


From   John Marvel <jdmarvel@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Marginsplot: Connecting margins in non-default order
Date   Mon, 2 Dec 2013 20:32:52 -0500

Hi everyone,

I'm running a regression in which I have two predictors--the first is
a three-category variable and the second is a two-category variable.
After running the regression, I'm using margins and marginsplot to
illustrate my results.  (I'm using Stata 13 SE).

I've pasted code (using the auto data) below to provide an idea of
what I'm doing.

sysuse auto
recode rep78 (1 2 = 3)
reg mpg rep78##foreign
margins rep78#foreign
marginsplot, noci

As you'll see, the code produces a graph in which the points are
connected in ascending order on the repair record variable.  And so
the connecting lines drawn are (for each value of the foreign
variable): [3 to 4] & [4 to 5].

My question is whether I can tell Stata to instead connect point 3 to
point 4 and point 3 to point 5, so that the connecting lines drawn
are: [3 to 4] & [3 to 5].

Substantively, my reason for wanting to do this is that category 3 is
my base category, and I want to compare the "effects" of category 4
and category 5 visually.  The default connecting order doesn't
facilitate this comparison.

(Incidentally, I've tried recoding my three-category variable so that
my base category is, numerically, the middle category.  This results
in a graph where both of my desired effects are depicted, but in a
non-intuitive way.  The reason for the non-intuitiveness is that one
of my effects is negative, but the connecting line drawn to illustrate
the effect is forced to be positively sloped).

Thank you,

John Marvel
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index