[R-sig-ME] a question of conducting contrast in lme4 (not pairwise contrast)

Ben Bolker bbolker at gmail.com
Fri Sep 2 22:35:49 CEST 2016


I may never have gotten around to covering that stuff in the class, but the
recipe is pretty simple: just google "multcomp glht tukey".  The
stats.stackexchange postings that you'll find deal with slightly more
complicated situations: if you just want to do pairwise tests on a
fixed-effect categorical predictor at the population level you can just
follow the recipes in the multcomp documentation.

CrossValidated:

http://stats.stackexchange.com/questions/145765/post-hoc-testing-in-multcompglht-for-mixed-effects-models-lme4-with-interact

http://stats.stackexchange.com/questions/5250/multiple-comparisons-on-a-mixed-effects-model



On Fri, Sep 2, 2016 at 3:15 PM, Price, Emily <ep311508 at ohio.edu> wrote:

> Hi Dr. Bolker,
>
>
> I am also working on a project with contrast codes.
>
>
> In my project I would like to investigate all the pairwise comparisons
> between a categorical variable with four levels.  In the second handout (
> http://ms.mcmaster.ca/~bolker/classes/s4c03/notes/week2B.pdf)  you
> mention discussing all pairwise comparisons later.  Would you be willing to
> share the link for the handout with the pairwise comparisons?
>
>
> Thank you!
>
> Emily
> STAT 4/6C03: notes, week 2, part 2 - McMaster University
> <http://ms.mcmaster.ca/~bolker/classes/s4c03/notes/week2B.pdf>
> ms.mcmaster.ca
> stat 4/6c03: notes, week 2, part 2 2 sensible not always completely
> compatible, ways, across add-on packages •The bar (|) is used as a grouping
> variable in various ...
>
> Emily A. Price, PhD
> Educational Research and Evaluation
> Patton College of Education
> Ohio University
> ------------------------------
> *From:* R-sig-mixed-models <r-sig-mixed-models-bounces at r-project.org> on
> behalf of Ben Bolker <bbolker at gmail.com>
> *Sent:* Friday, September 2, 2016 1:47:50 PM
> *To:* r-sig-mixed-models at r-project.org
> *Subject:* Re: [R-sig-ME] a question of conducting contrast in lme4 (not
> pairwise contrast)
>
>
>
> On 16-09-02 02:18 PM, Gu Hao wrote:
> > Hello,
> >
> > I am trying to do some contrasts using a mixed model, but don’t know
> > how to use it in lme4. I've done the multiple contrast, but I believe
> > the power of this method is lower than ideal. I think contrast in
> > lme4 would be a better option. I searched the question on
> > stackoverflow and found one post. However, the question asked wasn't
> > our situation.
> >
> > In our case, there are five treatments. Let’s call them AA, BB, CC,
> > DD, and EE.
> >
> > I have the following hypotheses:
> >
> > the response to AA will be higher than the average of BB, CC and DD.
> > the response to AA will be higher than EE the average response to BB,
> > CC and DD will be higher than EE.
>
> Some notes on linear contrasts:
>
> http://ms.mcmaster.ca/~bolker/classes/s4c03/notes/week2B.Rnw
> http://ms.mcmaster.ca/~bolker/classes/s4c03/notes/week2B.pdf
>
> The three contrasts you've set up are collinear: let's code them as
>
>    c1 = c(1, -1/3, -1/3, -1/3,  0)  ## AA vs (BB,CC,DD)
>    c2 = c(1,      0,      0,      0, -1) ## AA vs EE
>    c3 = c(0,  1/3,   1/3,  1/3, -1) ## (BB,CC,DD) vs EE
>
> then you can see that c1 + c3 is equal to c2.  Therefore, you can't use
> these three contrasts as part of a full set of 5 contrasts that span the
> space of possibilities.
>
>   Before I saw that you said you've already tried multcomp I wrote the
> following down; it might be useful to someone else.
>   Adapted from the examples in ?multcomp::glht
>
>
>  z <- gl(5,10,labels=LETTERS[1:5])
> y <- rnorm(50)
> library(multcomp)
>
> K <- rbind("A - BCD" = c( 1, -1/3, -1/3, -1/3,  0),
>            "A - E" =   c( 1,    0,    0,    0, -1),
>            "BCD-E" =   c( 0,  1/3,  1/3,  1/3, -1))
>
> m <- lm(y~z)
> mc <- glht(m,
>            linfct = mcp(z = K),
>            alternative = "less")
> summary(mc)
>
> If you want to live dangerously I think
>
> summary(mc,test=univariate())
>
> will give you the unadjusted p-values ...
>
>
>
> >
> > The model is being run in lme4 as a mixed model:
> >
> > response (binomial, 0 or 1) ~ treatment (the 5 levels above) +
> > (1|tape) + (1|round) + (1|location). Do anybody know how to code
> > this? Please kindly find the data in the attachment.
> >
> > With thanks and best wishes,
> >
> > Hao
> >
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list