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]

Re: st: Graphic displays or results from margins


From   Scott Merryman <[email protected]>
To   [email protected]
Subject   Re: st: Graphic displays or results from margins
Date   Mon, 20 Sep 2010 10:24:21 -0500

-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/


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