Compute the multi degrees-of-freedom test in a linear mixed model fitted
by lmer. The contrast (L) specifies a linear function of the
mean-value parameters, beta. Satterthwaite's method is used to compute the
denominator df for the F-test.
# S3 method for class 'lmerModLmerTest'
contestMD(
model,
L,
rhs = 0,
ddf = c("Satterthwaite", "Kenward-Roger"),
eps = sqrt(.Machine$double.eps),
...
)
calcSatterth(model, L)
# S3 method for class 'lmerMod'
contestMD(
model,
L,
rhs = 0,
ddf = c("Satterthwaite", "Kenward-Roger"),
eps = sqrt(.Machine$double.eps),
...
)a model object fitted with lmer from package
lmerTest, i.e., an object of class lmerModLmerTest.
a contrast matrix with nrow >= 1 and ncol ==
length(fixef(model)).
right-hand-side of the statistical test, i.e. the hypothesized
value. A numeric vector of length nrow(L) or a numeric scalar.
the method for computing the denominator degrees of freedom and
F-statistics. ddf="Kenward-Roger" uses Kenward-Roger's method.
tolerance on eigenvalues to determine if an eigenvalue is positive. The number of positive eigenvalues determine the rank of L and the numerator df of the F-test.
currently not used.
a data.frame with one row and columns with "Sum Sq",
"Mean Sq", "F value", "NumDF" (numerator df),
"DenDF" (denominator df) and "Pr(>F)" (p-value).
The F-value and associated p-value is for the hypothesis
\(L \beta = \mathrm{rhs}\) in which rhs may be non-zero
and \(\beta\) is fixef(model).
Note: NumDF = row-rank(L) is determined automatically so row rank-deficient L are allowed. One-dimensional contrasts are also allowed (L has 1 row).
data("sleepstudy", package="lme4")
fm <- lmer(Reaction ~ Days + I(Days^2) + (1|Subject) + (0+Days|Subject),
sleepstudy)
# Define 2-df contrast - since L has 2 (linearly independent) rows
# the F-test is on 2 (numerator) df:
L <- rbind(c(0, 1, 0), # Note: ncol(L) == length(fixef(fm))
c(0, 0, 1))
# Make the 2-df F-test of any effect of Days:
contestMD(fm, L)
#> Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
#> 1 30399.15 15199.57 2 54.40752 23.36102 4.744897e-08
# Illustrate rhs argument:
contestMD(fm, L, rhs=c(5, .1))
#> Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
#> 1 6116.15 3058.075 2 54.40752 4.700115 0.01309499
# Make the 1-df F-test of the effect of Days^2:
contestMD(fm, L[2, , drop=FALSE])
#> Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
#> 1 1079.503 1079.503 1 144.6311 1.659144 0.1997759
# Same test, but now as a t-test instead:
contest1D(fm, L[2, , drop=TRUE])
#> Estimate Std. Error df t value Pr(>|t|)
#> 1 0.3370223 0.2616475 144.6311 1.288078 0.1997759