kr_modcomp {pbkrtest} | R Documentation |
F-test and degrees of freedom based on Kenward-Roger approximation
Description
An approximate F-test based on the Kenward-Roger approach.
Usage
KRmodcomp(largeModel, smallModel, betaH = 0, details = 0)
## S3 method for class 'lmerMod'
KRmodcomp(largeModel, smallModel, betaH = 0, details = 0)
Arguments
largeModel |
An |
smallModel |
An |
betaH |
A number or a vector of the beta of the hypothesis,
e.g. L beta=L betaH. If |
details |
If larger than 0 some timing details are printed. |
Details
An F test is calculated according to the approach of Kenward and
Roger (1997). The function works for linear mixed models fitted
with the lmer() function of the lme4
package. Only models where
the covariance structure is a linear combination (a weighted sum)
of known matrices can be compared.
The smallModel
is the model to be tested against the largeModel
.
The largeModel
is a model fitted with lmer()
. A technical
detail: The model must be fitted with REML=TRUE
. If the model is
fitted with REML=FALSE
then the model is refitted with
REML=TRUE
before the p-values are calculated. Put differently,
the user needs not worry about this issue.
The smallModel
can be one of several things:
a model fitted with
lmer()
. It must have the same covariance structure aslargeModel
. Furthermore, its linear space of expectation must be a subspace of the space forlargeModel
.a restriction matrix
L
specifying the hypothesisL \beta = L \beta_H
where
L
is ak x p
matrix (there are k restrictions and p is the number of fixed effect parameters (the length offixef(largeModel)
) andbeta_H
is a p column vector.A formula or a text string specifying what is to be removed from the larger model to form the smaller model.
Notice: if you want to test a hypothesis
L \beta = c
with a k
vector c
, a suitable \beta_H
is obtained
via \beta_H=L c
where L_n
is a g-inverse of L
.
Notice: It cannot be guaranteed that the results agree with other implementations of the Kenward-Roger approach!
Author(s)
Ulrich Halekoh uhalekoh@health.sdu.dk, Søren Højsgaard sorenh@math.aau.dk
References
Ulrich Halekoh, Søren Højsgaard (2014)., A Kenward-Roger Approximation and Parametric Bootstrap Methods for Tests in Linear Mixed Models - The R Package pbkrtest., Journal of Statistical Software, 58(10), 1-30., https://www.jstatsoft.org/v59/i09/
Kenward, M. G. and Roger, J. H. (1997), Small Sample Inference for Fixed Effects from Restricted Maximum Likelihood, Biometrics 53: 983-997.
See Also
getKR
, lmer
,
vcovAdj
, PBmodcomp
,
SATmodcomp
Examples
(fm0 <- lmer(Reaction ~ (Days|Subject), sleepstudy))
(fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
(fm2 <- lmer(Reaction ~ Days + I(Days^2) + (Days|Subject), sleepstudy))
## Test for no effect of Days in fm1, i.e. test fm0 under fm1
KRmodcomp(fm1, "Days")
KRmodcomp(fm1, ~.-Days)
L1 <- cbind(0, 1)
KRmodcomp(fm1, L1)
KRmodcomp(fm1, fm0)
anova(fm1, fm0)
## Test for no effect of Days and Days-squared in fm2, i.e. test fm0 under fm2
KRmodcomp(fm2, "(Days+I(Days^2))")
KRmodcomp(fm2, ~. - Days - I(Days^2))
L2 <- rbind(c(0, 1, 0), c(0, 0, 1))
KRmodcomp(fm2, L2)
KRmodcomp(fm2, fm0)
anova(fm2, fm0)
## Test for no effect of Days-squared in fm2, i.e. test fm1 under fm2
KRmodcomp(fm2, "I(Days^2)")
KRmodcomp(fm2, ~. - I(Days^2))
L3 <- rbind(c(0, 0, 1))
KRmodcomp(fm2, L3)
KRmodcomp(fm2, fm1)
anova(fm2, fm1)