Skip to content

a question of conducting contrast in lme4 (not pairwise contrast)

4 messages · Gu Hao, Price, Emily, Ben Bolker

#
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.

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

--

??(GU HAO),
????, ???????????????????????,????????100????????519?? ???530005.

Research Associate, Behavioral and Community Ecology, Conservation Biology, Office 519, College of Forestry, Guangxi University,No. 100 Daxue Road, Nanning, Guangxi 530005, People?s Republic of China 

E-mail: longy213 at 163.com or guhao at xtbg.org.cn ; Cell phone: (+86) 18288055414; Lab Web: www.animal-ecology-guangxi.com; My Page:https://cn.linkedin.com/pub/hao-gu/80/95/9a3
#
On 16-09-02 02:18 PM, Gu Hao wrote:
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 ...
#
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
#
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: