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: margins & marginsplot when multiple outcomes are involved


From   Scott Merryman <[email protected]>
To   [email protected]
Subject   Re: st: margins & marginsplot when multiple outcomes are involved
Date   Tue, 28 Aug 2012 14:29:19 -0500

Here is one way, extracting the data from the -marginsplot- graphs :

webuse sysdsn1,clear
qui mlogit insure age male nonwhite i.site
tempfile tmp0 tmp1 tmp2

forv i = 1/3 {
	qui margins, at(age=(18 [5] 65)) predict(outcome(`i'))
	marginsplot, nodraw name(gr`i',replace)
}

forv i = 0/2 {
	serset set `i'
	serset use
	rename _* *`i'
	gen age = _ if `i' == 0
	drop _*
	save tmp`i', replace

	}
use tmp0
merge 1:1 _n using tmp1, nogenerate noreport
merge 1:1 _n using tmp2, nogenerate noreport
twoway rcap ci_lb0 ci_ub0 age, color(green) || connected margin0 age,
color(green)  ///
|| rcap ci_lb1 ci_ub1 age, color(blue) || connected margin1 age,
color(blue) ///
|| rcap ci_lb2 ci_ub2 age, color(red)  || connected margin2 age, color(red) ///
|| , legend(order( 1 "Indemnity" 2 "Prepaid" 3 "Uninsure"))

Scott



On Tue, Aug 28, 2012 at 4:11 AM, natalia malancu
<[email protected]> wrote:
> Hi all!
>
> I was wondering whether there is a way to combine the following
> commands into a single marginsplot.
>
> margins, at(age=(18 [5] 65)) predict(outcome(1))
> margins, at(age=(18 [5] 65)) predict(outcome(2))
> margins, at(age=(18 [5] 65)) predict(outcome(3))
>
>
> In the era of adjust this was fairly easy (line odds1 odds2
> odds3....), but with margins I don't seem to find a way to do so.
>
>
> Thanks for helping,
>
> Natalia
> *
> *   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