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 at the end of May, 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   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Graphic displays or results from margins
Date   Mon, 20 Sep 2010 19:50:21 +0200

<>

Not sure whether I am being helpful, but Roger`s -ssc d parmest-is also
available after -mergins, post-:


*************
cap which parmest
if _rc ssc inst parmest

webuse nhanes2f, clear
logit diabetes i.black i.female age i.female#c.age, nolog
margins female#black, at(age = (20(10)70)) post

parmest, saving(myfile, replace)

u myfile, clear
l
*************


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Phil Schumm
Sent: Montag, 20. September 2010 17:31
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: Graphic displays or results from margins

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/

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