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   Phil Schumm <pschumm@uchicago.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Graphic displays or results from margins
Date   Mon, 20 Sep 2010 10:30:32 -0500

On Sep 20, 2010, at 10:32 AM, Richard Williams 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 believe that the only option currently is to go manually through e(b). For example, if you add the -post- option to your -margins- command above, you could do something like this:


    mat A = e(b)'
    svmat A
    egen _age = fill(10 10 10 10 20 20 20 20)
    egen _grp = fill(1 2 3 4 1 2 3 4)
    separate A1, by(_grp)
    line A11-A14 _age if !mi(A1)


It wouldn't be difficult to write a little command to do this in a more general way (indeed, someone may have done it already).


-- Phil

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