[R-sig-ME] a question of conducting contrast in lme4 (not pairwise contrast)
ep311508 at ohio.edu
Fri Sep 2 21:15:57 CEST 2016
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?
STAT 4/6C03: notes, week 2, part 2 - McMaster University<http://ms.mcmaster.ca/~bolker/classes/s4c03/notes/week2B.pdf>
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
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:
> I am trying to do some contrasts using a mixed model, but dont 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. Lets 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:
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)
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")
If you want to live dangerously I think
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,
R-sig-mixed-models at r-project.org mailing list
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models