[R] How do I interpret linear mixed model contrast estimates from multcomp::glht()?
scoyoc
scoyoc at gmail.com
Mon Dec 15 18:08:27 CET 2014
How do the rows in the summary (e.g. "1 == 0") correspond to the model? The
answer is buried *contrast::contrast()*, but I can't figure it out.
Consider this modified example I stole from here
<https://stat.ethz.ch/pipermail/r-sig-mixed-models/2009q4/003061.html>...
> options(contrasts = c(factor = "contr.SAS", ordered = "contr.poly"))
> library("mlmRev")
> library("lme4")
> library("lmerTest")
> library("contrast")
> library("multcomp")
>
> data("egsingle")
> # Linear mixed model
> math.lmm <- lmer(math ~ year * size + female + (1|childid) +
(1|schoolid), egsingle)
> # Linear model
> math.lm <- lm(math ~ year * size + female, data = egsingle)
> # Calculate contrast matrix
> cc<-contrast(math.lm, a = list(year = c(0.5, 1.5, 2.5), size = 380,
female = levels(egsingle$female)), +
b = list(year = c(0.5, 1.5,
2.5), size = 800, female = levels(egsingle$female)))
> # Calculate estimates
> summary(glht(math.lmm, linfct = cc$X))
Simultaneous Tests for General Linear Hypotheses
Fit: lme4::lmer(formula = math ~ year * size + female + (1 | childid) +
(1 | schoolid), data = egsingle)
Linear Hypotheses:
Estimate Std. Error z value Pr(>|z|)
1 == 0 0.12774 0.08020 1.593 0.1272
2 == 0 0.15322 0.08066 1.900 0.0669 .
3 == 0 0.17870 0.08178 2.185 0.0341 *
4 == 0 0.12774 0.08020 1.593 0.1273
5 == 0 0.15322 0.08066 1.900 0.0669 .
6 == 0 0.17870 0.08178 2.185 0.0342 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Adjusted p values reported -- single-step method)
The row names correspond to the levels of *year* and *female,* and are
probably Female:0.5, Female:1.5, Female:2.5, and so on. But how do I pull
that out of the contrast() object *cc?* It might be simple with 3 fixed
effects, but my current project has 5 fixed effects, four 2-way
interactions, and one 3-way interaction, and the summary table has 24 rows.
Ultimately I would like to create a dataframe so I can plot the contrasts,
something like this...
> x = summary(glht(math.lmm, linfct = cc$X))
> # Contrast data frame
> math.contr = data.frame(Effect.Interaction = reference_something_in_cc,
Estimate =
x[["test"]]$coefficients, Std.Error = x[["test"]]$sigma)
Thanks for the help!
Cheers,
MVS
=====
Matthew Van Scoyoc
<mvanscoyoc at aggiemail.usu.edu>https://sites.google.com/site/scoyoc/
=====
Think SNOW!
-----
MVS
=====
Matthew Van Scoyoc
Graduate Research Assistant, Ecology
Wildland Resources Department & Ecology Center
Quinney College of Natural Resources
Utah State University
Logan, UT
=====
Think SNOW!
--
View this message in context: http://r.789695.n4.nabble.com/How-do-I-interpret-linear-mixed-model-contrast-estimates-from-multcomp-glht-tp4700797.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]
More information about the R-help
mailing list