varCompTest {varTestnlme} | R Documentation |
Variance component testing
Description
Perform a likelihood ratio test to test whether a subset of the variances of the random effects
are equal to zero. The test is defined by two hypotheses, H0 and H1, and the model under H0 is
assumed to be nested within the model under H1. These functions can be used on objects of class
lme
-, nlme
-, mer
-, lmerMod
, glmerMod
, nlmerMord
or SaemixObject
.
It is possible to tests if any subset of the variances are equal to zero. However, the function does not currently support nested random effects, and assumes that the random effects are Gaussian.
Usage
varCompTest(
m1,
m0,
control = list(M = 5000, parallel = T, nb_cores = 1, B = 1000),
pval.comp = "bounds",
fim = "extract",
output = TRUE
)
## S3 method for class 'lme'
varCompTest(
m1,
m0,
control = list(M = 5000, parallel = FALSE, nb_cores = 1, B = 1000),
pval.comp = "bounds",
fim = "extract",
output = TRUE
)
## S3 method for class 'merMod'
varCompTest(
m1,
m0,
control = list(M = 5000, parallel = FALSE, nb_cores = 1, B = 1000),
pval.comp = "bounds",
fim = "extract",
output = TRUE
)
## S3 method for class 'SaemixObject'
varCompTest(
m1,
m0,
control = list(M = 5000, parallel = FALSE, nb_cores = 1, B = 1000),
pval.comp = "bounds",
fim = "extract",
output = TRUE
)
Arguments
m1 |
a fit of the model under H1, obtained from |
m0 |
a fit of the model under H0, obtained from the same package as |
control |
(optional) a list of control options for the computation of the chi-bar-weights (see Details section) |
pval.comp |
(optional) the method to be used to compute the p-value, one of: |
fim |
(optional) the method to compute the Fisher Information Matrix. Options are: |
output |
a boolean specifying if any output should be printed in the console (default to TRUE) |
Details
The asymptotic distribution of the likelihood ratio test is a chi-bar-square, with weights that need to be
approximated by Monte Carlo methods, apart from some specific cases where they are available explicitly.
Therefore, the p-value of the test is not exact but approximated. This computation can be time-consuming, so
the default behaviour of the function is to provide bounds on the exact p-value, which can be enough in practice
to decide whether to reject or not the null hypothesis. This is triggered by the option pval.comp="bounds"
.
To compute an approximation of the exact p-value, one should use the option pval.comp="approx"
or pval.comp="both"
.
When pval.comp="approx"
or pval.comp="both"
, the weights of the chi-bar-square distribution are computed using Monte Carlo,
which might involve a larger computing time.
The control
argument controls the options for chi-bar-square weights computation. It is a list with the
following elements: M
the size of the Monte Carlo simulation, i.e. the number of samples generated, parallel
a
boolean to specify if parallel computing should be used, and nbcores
the number of cores to be used in case of
parallel computing. Default is M=5000
, parallel=FALSE
and nb_cores=1
.
If parallel=TRUE
but the value of nb_cores
is not given, then it is set to the number of detected
cores minus 1
Value
An object of class htest
with the following components:
-
statistic
the likelihood ratio test statistics -
null.value
-
alternative
-
parameters
the parameters of the limiting chi-bar-square distribution: the degrees of freedom and the weights of the chi-bar-square components and the Fisher Information Matrix -
method
a character string indicating the name of the test -
pvalue
a named vector containing the different p-values computed by the function: using the (estimated) weights, using the random sample from the chi-bar-square distribution, and the two bounds on the p-value.
Author(s)
Charlotte Baey <charlotte.baey@univ-lille.fr>
References
Baey C, Cournède P-H, Kuhn E, 2019. Asymptotic distribution of likelihood ratio test statistics for variance components in nonlinear mixed effects models. Computational Statistics and Data Analysis 135:107-122.
Silvapulle MJ, Sen PK, 2011. Constrained statistical inference: order, inequality and shape constraints.
Examples
# load lme4 package and example dataset
library(lme4)
data(Orthodont, package = "nlme")
# fit the two models under H1 and H0
m1 <- lmer(distance ~ 1 + Sex + age + age*Sex +
(0 + age | Subject), data = Orthodont, REML = FALSE)
m0 <- lm(distance ~ 1 + Sex + age + age*Sex, data = Orthodont)
# compare them (order is important: m1 comes first)
varCompTest(m1,m0,pval.comp="bounds")
# using nlme
library(nlme)
m1 <- lme(distance ~ 1 + Sex + age + age*Sex,
random = pdSymm(Subject ~ 1 + age), data = Orthodont, method = "ML")
m0 <- lme(distance ~ 1 + Sex, random = ~ 1 | Subject, data = Orthodont, method = "ML")
varCompTest(m1,m0)