[R] multi-comparison of means

meng laomeng_3 at 163.com
Wed Mar 13 12:15:01 CET 2013


Hi all:
I have a question about multi-comparison.
 
The data is in the attachment.
 
My purpose:
Compare the predicted means of the 3 methods(a,b,c) pairwisely.
 
I have 3 ideas:
 
#idea1
result_aov<-aov(y~ method + x1 + x2)
TukeyHSD(result_aov)
     diff        lwr       upr     p adj
b-a  0.845  0.5861098 1.1038902 0.0000001
c-a  0.790  0.5311098 1.0488902 0.0000002
c-b -0.055 -0.3138902 0.2038902 0.8578386

#idea2
library(multcomp)
summary(glht(result_aov,linfct=mcp(method="Tukey")))
         Estimate Std. Error t value Pr(>|t|)
b - a == 0   0.3239     0.1402   2.309   0.0683 .
c - a == 0  -0.3332     0.1937  -1.720   0.2069
c - b == 0  -0.6570     0.1325  -4.960   <0.001 ***
 
#idea3
#ref=a
dat$method <- relevel(dat$method, ref="a")
lm_ref_a<-lm(y~method + x1 + x2)
summary(lm_ref_a)
Coefficients:
            Estimate Std. Error t value Pr(>|t|)   
(Intercept)  0.92202    0.64418   1.431   0.1647   
methodb      0.32389    0.14025   2.309   0.0295 * 
methodc     -0.33316    0.19372  -1.720   0.0978 . 
x1           0.57935    0.09356   6.192 1.78e-06 ***
x2           0.13596    0.11563   1.176   0.2507   
 
#ref=b
dat$method <- relevel(dat$method, ref="b")
lm_ref_b<-lm(y~method + x1 + x2)
summary(lm_ref_b)

Coefficients:
            Estimate Std. Error t value Pr(>|t|)   
(Intercept)  1.24591    0.73770   1.689   0.1037   
methoda     -0.32389    0.14025  -2.309   0.0295 * 
methodc     -0.65705    0.13248  -4.960 4.14e-05 ***
 

In summary:
idea1:
a vs b:pvalue=0.0000001
a vs c:pvalue=0.0000002
b vs c:pvalue=0.8578386
idea2:
a vs b:pvalue=0.0683
a vs c:pvalue=0.2069
b vs c:pvalue<0.001
idea3:
a vs b:pvalue=0.0295
a vs c:pvalue=0.0978
b vs c:pvalue=4.14e-05

So the result of 3 ideas are different,and I don't know which one is correct.
Many thanks for your help.

My best
 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dat.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130313/9c4c2dd2/attachment.txt>


More information about the R-help mailing list