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: mlabel on marginsplot?


From   Steve Samuels <[email protected]>
To   [email protected]
Subject   Re: st: mlabel on marginsplot?
Date   Fri, 19 Oct 2012 19:47:51 -0400

An advantage of Ariel's approach is that one can format the _margin variable
before plotting. 

******************
sysuse auto,clear
qui reg price mpg
qui margins , at(mpg=(5(5)50))
marginsplot, plotopts(mlabel(_margin))
serset use
format _margin %6.0fc
twoway connected _margin __000000, mlabel(_margin, ) 
*******************

Steve

On Oct 19, 2012, at 5:42 PM, Phil Clayton wrote:

Slightly simpler (but needing a bit of tidying up) is:
sysuse auto,clear
reg price mpg
margins , at(mpg=(5(5)50))
marginsplot, plotopts(mlabel(_margin))

Phil

On 20/10/2012, at 6:10 AM, "Ariel Linden, DrPH" <[email protected]> wrote:

> As a followup, here is one solution based on Scott's suggested code below:
> 
> sysuse auto,clear
> reg price mpg
> margins , at(mpg=(5(5)50))
> marginsplot
> serset use
> twoway(connected _margin _ci_lb _ci_ub  __000000, mlabel( _margin ))
> 
> This can obviously be modified, but it works!
> 
> Ariel
> 
> -----Original Message-----
> From: Ariel Linden, DrPH [mailto:[email protected]] 
> Sent: Friday, October 19, 2012 10:03 AM
> To: [email protected]
> Subject: re: Re: Re: st: mlabel on marginsplot?
> 
> This is an excellent catch, Scott! Thank you (and Nick and Roger) for your
> replies!
> 
> Ariel
> 
> Date: Thu, 18 Oct 2012 09:54:48 -0500
> From: Scott Merryman <[email protected]>
> Subject: Re: Re: st: mlabel on marginsplot?
> 
> On Thu, Oct 18, 2012 at 9:23 AM, Nick Cox <[email protected]> wrote:
>> You are not giving specific examples of what you tried, but in general 
>> marker labels only work when the values  being plotted and the 
>> variable you want to use as marker label can be related by virtue of 
>> reading across observations. That is the structure is similar to
>> 
>> (y being plotted)  (x being plotted)  (z to use as marker label)
>> 
>> I haven't looked inside -marginsplot- but I think that the way that
>> -marginsplot- works is with a reduced dataset and that reduced dataset 
>> would need to include your marker label variable for this to work.
>> 
> 
> Can see the data set that -marginsplot- use by calling -serset use-  :
> 
> sysuse auto,clear
> reg price mpg
> margins , at(mpg=(5(5)50))
> marginsplot
> serset use
> 
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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