Learn R Programming

varTestnlme

varTestnlme implements the likelihood ratio test (LRT) for testing the presence of random effects in linear, generalized linear and nonlinear mixed-effects model. The test can be used to answer questions of the type:

  • should a certain subset of random effects be in fact considered as fixed effects?
  • is there any random effects in the model?
  • are there any correlation between two subsets of random effects?

It is possible to compare two models with different random effects, provided that the random structures of the two models are nested.

The package works on models that were fitted using nlme, lme4, or saemix packages.

Reference

Baey C, Kuhn E, 2023. varTestnlme: An R Package for Variance Components Testing in Linear and Nonlinear Mixed-Effects Models. Journal of Statistical Software. https://doi.org/10.18637/jss.v107.i06

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 Statistic and Data Analysis. 135:107–122 (2019), https://doi.org/10.1016/j.csda.2019.01.014

Installation

Install from CRAN:

install.packages("varTestnlme")

Or install the development version from Github:

install.packages("devtools")
devtools::install_github("baeyc/varTestnlme")

Example

An example using the nlme package.

Since version 1.0.0, the name of the main function has been changed from varTest to varCompTest due to a conflict with an existing function from package EnvStats.

library(nlme)
data("Orthodont")

# using nlme, with correlated slope and intercept
m1 <- lme(distance ~ 1 + Sex + age + age*Sex, random = pdSymm(Subject ~ 1 + age), data = Orthodont, method = "ML")
m0 <- lme(distance ~ 1 + Sex + age + age*Sex, random = ~ 1 | Subject, data = Orthodont, method = "ML")
vt <- varCompTest(m1,m0)
#> Variance components testing in mixed effects models
#> Testing that the variance of the random effect associated to age is equal to 0
#> Likelihood ratio test statistic:
#>  LRT = 0.8331072
#> 
#> p-value from exact weights: 0.5103454
#> 

It works similarly with lme4 package or saemix.

Copy Link

Version

Install

install.packages('varTestnlme')

Monthly Downloads

286

Version

1.3.5

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Charlotte Baey

Last Published

September 22nd, 2023

Functions in varTestnlme (1.3.5)

print.desc.message

print.desc.message
extractVarCov

Extract covariance matrix
extractStruct.merMod

Extract model structure
fim.vctest

Extract the Fisher Information Matrix
extractStruct.lme

Extract model structure
print.res.message

print.res.message
print.vctest

Print
extractVarCov.lme

Extract covariance matrix
summary.vctest

Summary
varCompTest

Variance component testing
weightsChiBarSquare

Monte Carlo approximation of chi-bar-square weights
bootinvFIM.merMod

Compute the inverse of the Fisher Information Matrix using parametric bootstrap
extractFIM.lme

Extract FIM
dfChiBarSquare

Chi-bar-square degrees of freedom computation
approxWeights

Monte Carlo approximation of chi-bar-square weights
bootinvFIM

Approximation of the inverse of the Fisher Information Matrix via parametric bootstrap
bootinvFIM.lme

Compute the inverse of the Fisher Information Matrix using parametric bootstrap
bootinvFIM.SaemixObject

Compute the inverse of the Fisher Information Matrix using parametric bootstrap
extractStruct

Extracting models' structures
alt.desc

alt.desc
pckName

Extract package name from a fitted mixed-effects model
null.desc

null.desc
objFunction

Internal functions for constrained minimization
extractStruct.SaemixObject

Extract model structure
extractVarCov.merMod

Extract covariance matrix