Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

RE: st: RE: marginsplot is acting differently


From   Richard Williams <richardwilliams.ndu@gmail.com>
To   statalist@hsphsun2.harvard.edu, <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: marginsplot is acting differently
Date   Sat, 31 Dec 2011 14:50:44 -0500

At 05:58 AM 12/31/2011, Philip Ryan wrote:
<<>>

Richard,

Further to our discussion on the behaviour of -marginsplot-, try this
(apologies in advance if line endings are zapped):

webuse nhanes2f, clear

logit diabetes i.black i.female age, nolog

margins, dydx(black female) at(age=(20 30 40 50 60 70)) vsquish
marginsplot, noci

margins r.black  r.female, at(age= (20 30 40 50 60 70)) vsquish
marginsplot, noci


The first -margins/marginsplot- sequence is as you tried, and yields the
unwanted base level lines.  The second is the alternative discussed on pages
1113-1114 of the manual and _should_ give "an identical graph" (para 1 page
1114), but this syntax yields a graph that omits the unwanted lines.

I don't know whether the first syntax's production of the base level lines
is a feature or a bug, but it doesn't appear to be consistent with (my
reading of) the manual.

Phil

Good catch Phil! Here is the code from that section of the manual, and, despite what the manual says, the two graphs are clearly NOT identical. The 2nd one has the same weird problem that I had, i.e. it presents a nonsensical line for the base category that is the same as the x-axis.

use http://www.stata-press.com/data/r12/nhanes2, clear
logistic highbp sex##agegrp##c.bmi
margins r.sex, at(bmi=(10(1)65))
marginsplot, xlabel(10(10)60) recast(line) recastci(rarea)
margins, at(bmi=(10(1)65)) dydx(sex)
marginsplot, xlabel(10(10)60) recast(line) recastci(rarea)

Given the apparent contradiction with the manual, it is even harder for me to believe that this is a "feature" rather than a bug. Further, I know I was getting the graph I wanted and expected back in September, and I can't think of any good reason that you would want to include base-level lines when they are the exact same as the X-axis. I also prefer the way the margins output is formatted with my preferred syntax, although, as the manual notes, such preferences are discipline-specific.

Nonetheless, unless or until my preferred syntax starts working the way I want it to, it is nice to know there is such a relatively painless work-around. Thanks!


-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:   (574)289-5227
EMAIL:  Richard.A.Williams.5@ND.Edu
WWW:    http://www.nd.edu/~rwilliam

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


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index