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: Graphic displays or results from margins


From   Scott Merryman <scott.merryman@gmail.com>
To   statalist@hsphsun2.harvard.edu
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
<richardwilliams.ndu@gmail.com> 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:  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/
>

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