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]
Re: st: Graphic displays or results from margins
From
Richard Williams <[email protected]>
To
[email protected]
Subject
Re: st: Graphic displays or results from margins
Date
Mon, 20 Sep 2010 20:16:35 -0500
Scott, thanks much. It never would have occurred to me to use Mata,
mostly because I don't know Mata. Perhaps still not as simple as I
would like, but to be able to do it at all is great. As far as
extracting the information in the r(b) matrix to relabel the legend,
that might be good, but I suspect it might be better just to go into
the graphics editor. I am not overly impressed with how margins
labels its own output, so it may just be that some manual
intervention is needed to get a nice looking graphic. (But I am about
as good with graphics as I am with Mata, so there may well be ways to
make this easier.)
Also thanks to everyone else who made suggestions. I will check them
out. If I come up with a better solution I will post it. I would like
to see a built-in Stata command or a user-written command that easily
generates such graphics -- it seems to me like the margins output
often cries out for a nice graphical display.
At 10:24 AM 9/20/2010, Scott Merryman wrote:
-margins- does have the post option.
As start, you could do something this:
webuse nhanes2f, clear
logit diabetes i.black i.female age i.female#c.age, nolog
margins female#black, at(age = (20(10)70)) post
matrix b = r(b)
matrix at = r(at)
mata
b =st_matrix("b")
b = rowshape(b,6)
st_matrix("b", b)
end
clear
svmat at
svmat b
line b* at5
It would be nice to extract the information in the r(b) matrix to
relabel the legend, but I am not sure how.
Scott
On Mon, Sep 20, 2010 at 10:32 AM, Richard Williams
<[email protected]> wrote:
> I am warming up to the new margins command. However, unlike the older
> adjust command, margins does not include the ability to generate new
> variables. I am therefore finding it hard to create graphic displays of the
> results.
>
> Consider the following:
>
> webuse nhanes2f, clear
> logit diabetes i.black i.female age i.female#c.age, nolog
> margins female#black, at(age = (20(10)70))
>
> I would love to create a graphic where the Y axis was the probability of
> diabetes, the X axis was age, and there were 4 separate lines, for black
> males, black females, nonblack males, nonblack females. I imagine I could
> generate variables myself (basically replicating what margins is doing) or
> (ugh!) cut and paste results into an excel spreadsheet. But, is there some
> nice, simple approach for doing this? The prgen command in Long & Freese's
> spost9 suite of commands can do things like this, but it doesn't support
> many of the features of margins, e.g. it doesn't work with factor
variables,
> and things like interaction terms are going to confuse it.
>
> -------------------------------------------
> Richard Williams, Notre Dame Dept of Sociology
> OFFICE: (574)631-6668, (574)631-6463
> HOME: (574)289-5227
> EMAIL: [email protected]
> 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/
>
*
* 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/
-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME: (574)289-5227
EMAIL: [email protected]
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/