jacob-long / jacob-long/jtools

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

Open Beginner friendly
#165 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
R
Stars
171
Forks
23
PR merge metrics
No merged PRs in 30d

Description

**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:**
``` r
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](https://reprex.tidyverse.org)

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

``` r
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).

Contributor guide

Open the contributing guide

Research direction

Start in the summ.merMod() implementation and reproduce the failure with the lme4 iris model shown in the issue using confint = TRUE. Inspect the the_cis subset used for the confidence intervals and verify that the single-intercept case remains a matrix. Done means the reprex runs without the incorrect number of dimensions error.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.