Compute the test of a one-dimensional (vector) contrast in a linear mixed model fitted with lmer from package lmerTest. The contrast should specify a linear function of the mean-value parameters, beta. The Satterthwaite or Kenward-Roger method is used to compute the (denominator) df for the t-test.
a model object fitted with lmer from package
lmerTest, i.e., an object of class lmerModLmerTest.
a numeric (contrast) vector of the same length as
fixef(model).
right-hand-side of the statistical test, i.e. the hypothesized value (a numeric scalar).
the method for computing the denominator degrees of freedom.
ddf="Kenward-Roger" uses Kenward-Roger's method.
include columns for lower and upper confidence limits?
confidence level.
currently not used.
A data.frame with one row and columns with "Estimate",
"Std. Error", "t value", "df", and "Pr(>|t|)"
(p-value). If confint = TRUE "lower" and "upper" columns
are included before the p-value column.
The t-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).
The estimated value ("Estimate") is \(L' \beta\) with associated
standard error and (optionally) confidence interval.
# Fit model using lmer with data from the lme4-package:
data("sleepstudy", package="lme4")
fm <- lmer(Reaction ~ Days + (1 + Days|Subject), sleepstudy)
# Tests and CI of model coefficients are obtained with:
contest1D(fm, c(1, 0), confint=TRUE) # Test for Intercept
#> Estimate Std. Error df t value lower upper Pr(>|t|)
#> 1 251.4051 6.824597 16.99973 36.83809 237.0064 265.8038 1.171558e-17
contest1D(fm, c(0, 1), confint=TRUE) # Test for Days
#> Estimate Std. Error df t value lower upper Pr(>|t|)
#> 1 10.46729 1.54579 16.99998 6.771481 7.205955 13.72862 3.263824e-06
# Tests of coefficients are also part of:
summary(fm)
#> Linear mixed model fit by REML. t-tests use Satterthwaite's method [
#> lmerModLmerTest]
#> Formula: Reaction ~ Days + (1 + Days | Subject)
#> Data: sleepstudy
#>
#> REML criterion at convergence: 1743.6
#>
#> Scaled residuals:
#> Min 1Q Median 3Q Max
#> -3.9536 -0.4634 0.0231 0.4634 5.1793
#>
#> Random effects:
#> Groups Name Variance Std.Dev. Corr
#> Subject (Intercept) 612.10 24.741
#> Days 35.07 5.922 0.07
#> Residual 654.94 25.592
#> Number of obs: 180, groups: Subject, 18
#>
#> Fixed effects:
#> Estimate Std. Error df t value Pr(>|t|)
#> (Intercept) 251.405 6.825 17.000 36.838 < 2e-16 ***
#> Days 10.467 1.546 17.000 6.771 3.26e-06 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Correlation of Fixed Effects:
#> (Intr)
#> Days -0.138
# Illustrate use of rhs argument:
contest1D(fm, c(0, 1), confint=TRUE, rhs=10) # Test for Days-coef == 10
#> Estimate Std. Error df t value lower upper Pr(>|t|)
#> 1 10.46729 1.54579 16.99998 0.302296 7.205955 13.72862 0.7660937