Skip to content

summ() throws "incorrect number of dimensions" error when using random intercepts lmer model with confint = TRUE #165

Description

@koenniem

Description:
When using summ() with an random intercept multilevel model and setting confint = TRUE, the function fails with an index out of bounds error. This is caused by dropped dimensions when computing the confidence intervals.

Reprex:

library(lme4)
#> Loading required package: Matrix
library(jtools)

model <- lmer(Petal.Length ~ 1 + (1 | Species), data = iris)
summ(model, confint = TRUE)
#> Error in the_cis[, 1]: incorrect number of dimensions

Created on 2025-06-19 with reprex v2.1.1

Proposed solution:
When computing the_cis in summ.merMod(), consider adding the drop = FALSE argument to the subset:

the_cis <- confint(model, parm = "beta_", method = conf.method[1], level = ci.width)
the_cis <- the_cis[rownames(the_sum$coefficients), , drop = FALSE]

This argument will prevent the_cis to be simplified from a matrix to a vector when there is only one row (i.e. the intercept).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions