Formatting inconsistency in estimate_grouplevel() with a categorical predictor
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 50/100
Research direction
Start with the estimate_grouplevel() entry point and reproduce the issue using the lmer model and categorical treatment predictor shown in the report. Trace how the Parameter column is formatted across grouping levels. Done means every random-slope row uses consistent factor-level formatting, and the reproducer output no longer mixes bracketed and raw names.
Written by the indexing model from the issue text.
Description
When extracting random effects from an lmer model using estimate_grouplevel(), the formatting of factor levels in the Parameter column is inconsistent. The first instance of a factor's random slope gets cleaned up nicely (e.g., treatment [1]), but all subsequent rows for that same parameter revert to the raw lme4 naming convention (e.g., treatment1).
library(lme4)
#> Loading required package: Matrix
library(easystats)
#> # Attaching packages: easystats 0.7.5
#> ✔ bayestestR 0.17.0 ✔ correlation 0.8.8
#> ✔ datawizard 1.3.0 ✔ effectsize 1.0.1
#> ✔ insight 1.4.6 ✔ modelbased 0.14.0
#> ✔ performance 0.16.0 ✔ parameters 0.28.3
#> ✔ report 0.6.3 ✔ see 0.13.0
# Prepare built-in data with a 0/1 categorical predictor
dat <- sleepstudy |>
dplyr::mutate(treatment = factor(ifelse(Days > 4, "1", "0")))
# Fit a model with a random slope for the factor
fit <- lmer(Reaction ~ treatment + (1 + treatment | Subject), data = dat)
# Extract random effects
# Notice Subject 308 gets "treatment [1]" while 309+ get "treatment1"
estimate_grouplevel(fit, type = "random")
#> Group | Level | Parameter | Coefficient | SE | 95% CI
#> ------------------------------------------------------------------------
#> Subject | 308 | (Intercept) | 21.70 | 10.38 | [ 1.36, 42.04]
#> Subject | 308 | treatment [1] | 42.41 | 14.18 | [ 14.61, 70.20]
#> Subject | 309 | (Intercept) | -55.24 | 10.38 | [-75.58, -34.90]
#> Subject | 309 | treatment1 | -44.64 | 14.18 | [-72.44, -16.85]
#> Subject | 310 | (Intercept) | -45.89 | 10.38 | [-66.23, -25.55]
#> Subject | 310 | treatment1 | -33.27 | 14.18 | [-61.06, -5.48]
#> Subject | 330 | (Intercept) | 11.64 | 10.38 | [ -8.70, 31.98]
#> Subject | 330 | treatment1 | -19.84 | 14.18 | [-47.64, 7.95]
#> Subject | 331 | (Intercept) | 16.66 | 10.38 | [ -3.68, 37.00]
#> Subject | 331 | treatment1 | -18.86 | 14.18 | [-46.66, 8.93]
#> Subject | 332 | (Intercept) | 4.69 | 10.38 | [-15.65, 25.03]
#> Subject | 332 | treatment1 | 7.72 | 14.18 | [-20.08, 35.51]
#> Subject | 333 | (Intercept) | 13.59 | 10.38 | [ -6.75, 33.93]
#> Subject | 333 | treatment1 | 4.51 | 14.18 | [-23.28, 32.31]
#> Subject | 334 | (Intercept) | -4.43 | 10.38 | [-24.77, 15.91]
#> Subject | 334 | treatment1 | 4.34 | 14.18 | [-23.45, 32.14]
#> Subject | 335 | (Intercept) | -22.23 | 10.38 | [-42.57, -1.89]
#> Subject | 335 | treatment1 | -51.99 | 14.18 | [-79.78, -24.19]
#> Subject | 337 | (Intercept) | 49.50 | 10.38 | [ 29.16, 69.84]
#> Subject | 337 | treatment1 | 45.91 | 14.18 | [ 18.11, 73.70]
#> Subject | 349 | (Intercept) | -20.23 | 10.38 | [-40.58, 0.11]
#> Subject | 349 | treatment1 | 1.49 | 14.18 | [-26.30, 29.29]
#> Subject | 350 | (Intercept) | -1.37 | 10.38 | [-21.72, 18.97]
#> Subject | 350 | treatment1 | 38.02 | 14.18 | [ 10.22, 65.81]
#> Subject | 351 | (Intercept) | -1.65 | 10.38 | [-21.99, 18.69]
#> Subject | 351 | treatment1 | -14.84 | 14.18 | [-42.63, 12.96]
#> Subject | 352 | (Intercept) | 28.95 | 10.38 | [ 8.61, 49.29]
#> Subject | 352 | treatment1 | 12.62 | 14.18 | [-15.17, 40.42]
#> Subject | 369 | (Intercept) | 5.29 | 10.38 | [-15.05, 25.63]
#> Subject | 369 | treatment1 | 3.26 | 14.18 | [-24.53, 31.06]
#> Subject | 370 | (Intercept) | -15.14 | 10.38 | [-35.48, 5.20]
#> Subject | 370 | treatment1 | 24.26 | 14.18 | [ -3.53, 52.06]
#> Subject | 371 | (Intercept) | 0.73 | 10.38 | [-19.61, 21.07]
#> Subject | 371 | treatment1 | -9.96 | 14.18 | [-37.75, 17.84]
#> Subject | 372 | (Intercept) | 13.44 | 10.38 | [ -6.90, 33.78]
#> Subject | 372 | treatment1 | 8.86 | 14.18 | [-18.94, 36.65]
Created on 2026-03-01 with reprex v2.1.1
Expected Behavior
The Parameter column should apply the factor [level] formatting consistently across all grouping levels rather than just the first one.
- Dominant language
- R
- Stars
- 263
- Forks
- 22
- Avg merge
- 1h 37m
- Merged PRs (30d)
- 9
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from easystats/modelbased
-
What's your opinion :hear_no_evil:
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
easystats/modelbased#651 · 3 comments ·
-
What's your opinion :hear_no_evil:
Difficulty 5/5 Over a week Newbie friendliness 35/100
easystats/modelbased#609 · 3 comments ·
-
Enhancement :boom:
Difficulty 5/5 Over a week Newbie friendliness 25/100
easystats/modelbased#591 · 3 comments ·
-
3 investigators :grey_question::question: Consistency :green_apple: :apple:
Difficulty 4/5 3-5 days Newbie friendliness 35/100
easystats/modelbased#579 · 9 comments ·
-
What's your opinion :hear_no_evil:
Difficulty 3/5 1-2 days Newbie friendliness 35/100
easystats/modelbased#569 · 4 comments ·
All issues in easystats/modelbased
Similar issues
-
bug priority: should
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
The-Strategy-Unit/nhp_outputs#477 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Open-Systems-Pharmacology/OSPSuite.ReportingEngine#1380 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Open-Systems-Pharmacology/OSPSuite.ParameterIdentification#335 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100