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: contrasts
From 
 
Nikolaos Pandis <[email protected]> 
To 
 
"[email protected]" <[email protected]> 
Subject 
 
Re: st: contrasts 
Date 
 
Tue, 2 Oct 2012 06:26:45 -0700 (PDT) 
Many thanks Jeff-it looks good
Nick
________________________________
From: Jeffrey Pitblado <[email protected]>
To: [email protected] 
Sent: Tuesday, October 2, 2012 5:32 AM
Subject: Re: st: contrasts
Nikolaos Pandis <[email protected]> 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
  [email protected]
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?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/