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: difference between -test- and -contrast- in Statat 12


From   Ricardo Ovaldia <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: difference between -test- and -contrast- in Statat 12
Date   Fri, 26 Aug 2011 05:13:34 -0700 (PDT)

 
Thank you Richard.

Ricardo Ovaldia, MS
Statistician 
Oklahoma City, OK


----- Original Message -----
From: Richard Williams <[email protected]>
To: [email protected]; "[email protected]" <[email protected]>
Cc: 
Sent: Thursday, August 25, 2011 10:33 PM
Subject: Re: st: difference between -test- and -contrast- in Statat 12

At 10:15 PM 8/25/2011, Ricardo Ovaldia wrote:
>
>I am using the new -contrast- command in Stata 12 to test a contrast 
>after ANOVA and I get different p-values than when using -test- 
>although the marginal means are the same.

My guess is that it is because the first statistic is an F statistic 
with d.f. 1, 63 while the 2nd statistic is chi-square(1). Since N is 
small the P values don't match exactly. I added [fw=15] to your anova 
command (to make the sample larger] and the P values were the same to 
at least 4 decimal places. Try it with larger samples (or just 
inflate your own sample using fweights) and see if the discrepancies disappear.

>
>I illustrate with the auto data by first making the rep78 variable a 
>3 level variable and then running an ANOVA follow by -contrast-:
>
>. sysuse auto,clear
>. replace rep78=3 if rep78<3
>. anova price rep78##foreign
>  <output omitted>
>. contrast r.foreign@rep78
>
>Contrasts of marginal linear predictions
>
>Margins      : asbalanced
>
>-------------------------------------------------
>              |        df          F        P>F
>--------------+----------------------------------
>foreign@rep78 |
>  (1 vs 0) 3  |          1        0.73    0.3965
>  (1 vs 0) 4  |          1        0.07    0.7881
>  (1 vs 0) 5  |          1        0.80    0.3743
>        Joint  |          3        0.53    0.6606
>              |
>      Residual |        63
>-------------------------------------------------
>
>---------------------------------------------------------------
>              |  Contrast  Std. Err.    [95% Conf. Interval]
>--------------+------------------------------------------------
>foreign@rep78 |
>  (1 vs 0) 3  |  -1529.739  1792.049    -5110.862    2051.385
>  (1 vs 0) 4  |  379.8889  1407.262      -2432.3    3192.078
>  (1 vs 0) 5  |  2088.167  2333.681    -2575.322    6751.655
>---------------------------------------------------------------
>
> From the above tables the p-value for the test of foreign withing 
> rep78=3 is: p=0.3965
>
>Now using -margin, post- follow by -test- for the same comparison 
>(i.e.  foreign withing rep78=3):
>. margins ,over(rep78 foreign) post cformat(%5.2f)
>
>Predictive margins                                Number of obs  =        69
>
>Expression  : Linear prediction, predict()
>over        : rep78 foreign
>
>-------------------------------------------------------------------------------
>              |            Delta-method
>              |    Margin  Std. Err.      z    P>|z|    [95% 
> Conf. Interval]
>--------------+----------------------------------------------------------------
>rep78#foreign |
>          3 
> 0  |    6358.41    490.77    12.96  0.000      5396.51    7320.30
>          3 
> 1  |    4828.67    1723.54    2.80  0.005      1450.60    8206.74
>          4 
> 0  |    5881.56    995.08    5.91  0.000      3931.23    7831.89
>          4 
> 1  |    6261.44    995.08    6.29  0.000      4311.11    8211.77
>          5 
> 0  |    4204.50    2110.89    1.99  0.046        67.22    8341.78
>          5 
> 1  |    6292.67    995.08    6.32  0.000      4342.34    8243.00
>-------------------------------------------------------------------------------
>
>. test 0.foreign#3.rep78=1.foreign#3.rep78
>
>  ( 1)  3bn.rep78#0bn.foreign - 3bn.rep78#1.foreign = 0
>
>            chi2(  1) =    0.73
>          Prob > chi2 =    0.3933
>
>I get a different p-value. Although close in this example, in 
>another case that have the p-values are further apart: (0.0026 vs 0.0089).
>Why are these two methods giving different answers?
>
>Thank you,
>Ricardo
>
>Ricardo Ovaldia, MS
>Statistician
>Oklahoma City, OK
>
>
>*
>*  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/

-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:  (574)289-5227
EMAIL:  [email protected]
WWW:    http://www.nd.edu/~rwilliam

*
*  For searches and help try:
*  http://www.stata.com/help.cgi?searchhttp://www.stata.com/support/statalist/faqhttp://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