reconf

Score-based confidence intervals and hypothesis tests for variances and covariances of random effects in linear mixed models fitted with lme4.

Overview

reconf computes confidence intervals and score tests for the variances and covariances of random effects in linear mixed models. The intervals invert a profile score statistic on the variance-covariance scale, with nuisance parameters estimated on an extended parameter set. The intervals have near-nominal coverage, even near the boundary of the parameter space where Wald and likelihood ratio intervals can be unreliable; see the references.

Coverage

Estimated coverage of 95% confidence intervals for a random-intercept variance

The figure shows the estimated coverage of 95% intervals for a random-intercept variance, with 30 groups of 5 observations and 2000 replicates at each of eleven values of the variance. Across those values, the coverage was between 0.941 and 0.960 for the score intervals, between 0.914 and 0.998 for Wald intervals, and between 0.937 and 0.978 for profile likelihood intervals; the Monte Carlo standard errors are at most 0.0063. The simulation is coverage_simulation.R in the scripts folder of the repository.

On the FEV1 model of the vignette, vc_ci() computed the four intervals in 0.7 s and confint(fit, method = "profile") in 28 s, in one run on a laptop.

Installation

install.packages("reconf")

# Development version
remotes::install_github("koekvall/reconf")

Usage

library(lme4)
library(reconf)

# Fit a linear mixed model
fit <- lmer(Reaction ~ Days + (Days | Subject), data = sleepstudy)

# 95% score-based CIs for all covariance parameters, residual variance included
vc_ci(fit)

# CI for selected parameters, by name or index
vc_ci(fit, parm = "var_(Intercept)|Subject")

# Score test that the random slope variance (index 3) is zero
vc_test(fit, parm = 3)

# Score test that all random-effect covariance parameters are zero
vc_test(fit)

# Build the model once to reuse its precomputation across calls
m <- vc_model(fit)
vc_ci(m, parm = 3)

# Log-likelihood, score, and information at any covariance parameters
ll <- vc_loglik(fit)
ll(c(600, 10, 35, 650))

The parameter ordering follows as.data.frame(VarCorr(fit), order = "lower.tri"), with the residual variance last.

References

varcomp (formerly lmmvar) implements the method of Zhang, Ekvall, and Molstad (2025) for a model with one variance component and an error term, with the proportion of variability (heritability) as the parameter of interest. reconf instead treats the variances and covariances themselves as the parameters of interest and covers all covariance parameters in models fitted with lme4.