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: contrasts


From   Nikolaos Pandis <npandis@yahoo.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: contrasts
Date   Tue, 2 Oct 2012 06:26:45 -0700 (PDT)

Many thanks Jeff-it looks good

Nick

________________________________
From: Jeffrey Pitblado <jpitblado@stata.com>
To: statalist@hsphsun2.harvard.edu 
Sent: Tuesday, October 2, 2012 5:32 AM
Subject: Re: st: contrasts

Nikolaos Pandis <npandis@yahoo.com> originally asked about
plotting margin contrasts, but I jumped to pairwise comparisons of
margins when I noticed the third comparison in the original email.
Nick's follow-up comment on my reply was:

> Thank you for the suggestion.
>
> marginsplot after :
>
> margins r.wiretype,contrast
>
> looks neater compared to:
>
> margins wiretype, pwcompare

Nick can get -margins- to plot any number of contrasts of margins,
the trick is employing user-defined contrasts.  Here is a rework
of Nick's original example that also includes the 3 vs 2 contrast:

    margins {wiretype -1  1 0} /// 2 vs 1
        {wiretype -1  0 1} /// 3 vs 1
        {wiretype  0 -1 1}  // 3 vs 2

While user-defined contrasts require more from the user in order to
specify them, user-defined contrasts also give the user the most amount
of control.

--Jeff Pitblado
  jpitblado@stata.com

PS:

Here the example code I was playing with while thinking about
Nick's query:

* BEGIN
sysuse auto

gen fac = (rep<4) + 2*(rep==4) + 3*(rep==5)

keep if fac

regress mpg i.fac

margins r.fac
marginsplot, name(contrast)

margins fac, pwcompare
marginsplot, name(pwcompare)

margins    {fac -1  1 0}    ///
    {fac -1  0 1}    ///
    {fac  0 -1 1}
marginsplot, name(user)
* END


*
*  For searches and help try:
*  http://www.stata.com/help.cgi?searchhttp://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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index