[R-sig-ME] a question of conducting contrast in lme4 (not pairwise contrast)
Ben Bolker
bbolker at gmail.com
Fri Sep 2 20:47:50 CEST 2016
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
>
More information about the R-sig-mixed-models
mailing list