`check_predictions()` fails for brms models with `dec()` (Wiener and RT-choice families)
Maintainers usually reply within 2 days
@DominiqueMakowski is already working on this.
Since Oct 14, 2026.
- #972 by @copilot-swe-agent — open
Assessment
This issue has not been assessed yet.
Description
Problem
check_predictions() errors on brms models whose response is
rt | dec(choice), i.e. the native wiener() family and custom choice-RT
families such as cogmod::cogmod_ddm():
Error in str2lang(insight::find_response(model)) :
argument must be a character string
There are two problems, and fixing the first alone exposes the second:
- For
rt | dec(resp),insight::find_response()returns
c("rt", "resp")andinsight::get_response()returns a data frame of
both. Sostr2lang()receives a length-2 vector. modelbased::estimate_prediction()returns 2N rows for these models,
anrtblock and aresponseblock distinguished by aComponentcolumn.
So the simulations would not line up with the N observed RTs in
out$y <- response.
Reprex
library(brms)
options(wiener_backend = "rtdists") # for posterior_predict(); RWiener works too
set.seed(1)
sim <- rbind(
rtdists::rdiffusion(150, a = 1.5, v = 0.5, t0 = 0.3, z = 0.75),
rtdists::rdiffusion(150, a = 1.5, v = 1.5, t0 = 0.3, z = 0.75)
)
d <- data.frame(
x = rep(c("a", "b"), each = 150),
rt = sim$rt,
resp = as.integer(sim$response == "upper")
)
m <- brm(bf(rt | dec(resp) ~ x), data = d, family = wiener(),
chains = 1, iter = 400, refresh = 0, seed = 1)
performance::check_predictions(m)
#> Error in str2lang(insight::find_response(model)) :
#> argument must be a character string
insight::find_response(m)
#> [1] "rt" "resp"
p <- modelbased::estimate_prediction(m, iterations = 5, keep_iterations = TRUE)
nrow(p) # 600, for 300 observations
table(p$Component)
#> response rt
#> 300 300
Cause
check_predictions.stanreg(), which check_predictions.brmsfit() is an alias
of (R/check_predictions.R, L248-253 on main):
response <- insight::get_response(model)
if (is.data.frame(response)) {
response <- eval(
str2lang(insight::find_response(model)),
envir = insight::get_response(model)
)
}
Suggested fix
Check the RT part of the model: keep the rt block of the predictions, and
the RT column of the response.
out <- modelbased::estimate_prediction(model, iterations = iterations,
keep_iterations = TRUE, re_formula = re_formula,
verbose = verbose, ...)
# Wiener / RT-choice models predict two components; check the RTs
is_rt_model <- isTRUE(minfo$is_wiener) || isTRUE(minfo$is_rtchoice)
if (is_rt_model && "Component" %in% colnames(out)) {
out <- out[out$Component == "rt", , drop = FALSE]
}
# ... unchanged ...
response <- insight::get_response(model)
if (is.data.frame(response)) {
if (is_rt_model) {
response <- response[[insight::find_response(model)[1]]]
} else {
response <- eval(str2lang(insight::find_response(model)), envir = response)
}
}
Tested on the model above: 300 x 50 simulations against 300 observed RTs, with
rows aligned with the data. A later option could check the choice proportions
too, from the Component == "response" block, but checking the RTs alone is
already what brms's pp_check() does for these models.
Versions
R 4.5.3, brms 2.23.1, insight 1.5.4.2, modelbased 0.17.0.6, performance
0.18.2. The code above is unchanged on main (0.18.2.16).
- Dominant language
- R
- Stars
- 1.2k
- Forks
- 108
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 20
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/performance
-
Enhancement :boom:
Difficulty 3/5 1-2 days Newbie friendliness 48/100
easystats/performance#908 · 1 assignee ·
Maintainers usually reply within 2 days
-
Docs :books: Enhancement :boom:
Difficulty 5/5 Over a week Newbie friendliness 45/100
easystats/performance#901 · 3 comments · 1 reaction ·
Maintainers usually reply within 2 days
-
Enhancement :boom:
Difficulty 4/5 3-5 days Newbie friendliness 35/100
easystats/performance#891 ·
Maintainers usually reply within 2 days
-
3 investigators :grey_question::question: Enhancement :boom:
Difficulty 4/5 3-5 days Newbie friendliness 45/100
easystats/performance#849 · 9 comments ·
Maintainers usually reply within 2 days
-
Enhancement :boom:
Difficulty 4/5 3-5 days Newbie friendliness 35/100
easystats/performance#825 ·
Maintainers usually reply within 2 days
All issues in easystats/performance
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
bennettoxford/opencodecounts#170 ·
-
complexity::1-low effort::1-hours priority::3-could
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
jumpingrivers/audit.workbench#43 ·
Maintainers usually reply within 1 day
-
complexity::1-low effort::1-hours priority::3-could
Difficulty 1/5 Under an hour Newbie friendliness 85/100
jumpingrivers/audit.connect#71 ·
Maintainers usually reply within 1 day
-
bug complexity::1-low effort::1-hours priority::2-should
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
jumpingrivers/audit.base#61 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
pharmaverse/admiraldev#580 ·