contest.lmerModLmerTest: Test of Contrasts

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/contest.R

Description

Tests of vector or matrix contrasts for lmer model fits.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## 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 lmer from package lmerTest, i.e., an object of class lmerModLmerTest.

L

a contrast vector or matrix or a list of these. The length/ncol of each contrasts should equal length(fixef(model)).

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 FALSE single DF t-tests are applied to each vector or each row of contrasts matrices.

collect

collect list of tests in a matrix?

confint

include columns for lower and upper confidence limits? Applies when joint is FALSE.

level

confidence level.

check_estimability

check estimability of contrasts? Only single DF contrasts are checked for estimability thus requiring joint = FALSE to take effect. See details section for necessary adjustments to L when estimability is checked with rank deficient design matrices.

ddf

the method for computing the denominator degrees of freedom. ddf="Kenward-Roger" uses Kenward-Roger's method.

...

passed to contestMD.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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)

lmerTest documentation built on Oct. 23, 2020, 6:16 p.m.