| contest.lmerModLmerTest {lmerTest} | R Documentation |
Test of Contrasts
Description
Tests of vector or matrix contrasts for lmer model fits.
Usage
## S3 method for class 'lmerModLmerTest'
contest(
model,
L,
rhs = 0,
joint = TRUE,
collect = TRUE,
confint = TRUE,
level = 0.95,
check_estimability = FALSE,
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"),
...
)
## S3 method for class 'lmerMod'
contest(
model,
L,
rhs = 0,
joint = TRUE,
collect = TRUE,
confint = TRUE,
level = 0.95,
check_estimability = FALSE,
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"),
...
)
Arguments
model |
a model object fitted with |
L |
a contrast vector or matrix or a list of these.
The |
rhs |
right-hand-side of the statistical test, i.e. the hypothesized value (a numeric scalar). |
joint |
make an F-test of potentially several contrast vectors? If
|
collect |
collect list of tests in a matrix? |
confint |
include columns for lower and upper confidence limits? Applies
when |
level |
confidence level. |
check_estimability |
check estimability of contrasts? Only single DF
contrasts are checked for estimability thus requiring |
ddf |
the method for computing the denominator degrees of freedom.
|
... |
passed to |
Details
If the design matrix is rank deficient, lmer drops columns for the
aliased coefficients from the design matrix and excludes the corresponding
aliased coefficients from fixef(model). When estimability is checked
the original rank-deficient design matrix is recontructed and therefore
L contrast vectors need to include elements for the aliased
coefficients. Similarly when L is a matrix, its number of columns
needs to match that of the reconstructed rank-deficient design matrix.
Value
a data.frame or a list of data.frames.
Author(s)
Rune Haubo B. Christensen
See Also
contestMD for multi
degree-of-freedom contrast tests,
and contest1D for tests of
1-dimensional contrasts.
Examples
data("sleepstudy", package="lme4")
fm <- lmer(Reaction ~ Days + I(Days^2) + (1|Subject) + (0+Days|Subject),
sleepstudy)
# F-test of third coeffcients - I(Days^2):
contest(fm, c(0, 0, 1))
# Equivalent t-test:
contest(fm, L=c(0, 0, 1), joint=FALSE)
# Test of 'Days + I(Days^2)':
contest(fm, L=diag(3)[2:3, ])
# Other options:
contest(fm, L=diag(3)[2:3, ], joint=FALSE)
contest(fm, L=diag(3)[2:3, ], joint=FALSE, collect=FALSE)
# Illustrate a list argument:
L <- list("First"=diag(3)[3, ], "Second"=diag(3)[-1, ])
contest(fm, L)
contest(fm, L, collect = FALSE)
contest(fm, L, joint=FALSE, confint = FALSE)
contest(fm, L, joint=FALSE, collect = FALSE, level=0.99)
# Illustrate testing of estimability:
# Consider the 'cake' dataset with a missing cell:
data("cake", package="lme4")
cake$temperature <- factor(cake$temperature, ordered=FALSE)
cake <- droplevels(subset(cake, temperature %in% levels(cake$temperature)[1:2] &
!(recipe == "C" & temperature == "185")))
with(cake, table(recipe, temperature))
fm <- lmer(angle ~ recipe * temperature + (1|recipe:replicate), cake)
fixef(fm)
# The coefficient for recipeC:temperature185 is dropped:
attr(model.matrix(fm), "col.dropped")
# so any contrast involving this coefficient is not estimable:
Lmat <- diag(6)
contest(fm, Lmat, joint=FALSE, check_estimability = TRUE)