Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

`check_predictions()` fails for brms models with `dec()` (Wiener and RT-choice families)

Open
#971 0 comments 1 reaction 2 assignees View on GitHub

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:

  1. For rt | dec(resp), insight::find_response() returns
    c("rt", "resp") and insight::get_response() returns a data frame of
    both. So str2lang() receives a length-2 vector.
  2. modelbased::estimate_prediction() returns 2N rows for these models,
    an rt block and a response block distinguished by a Component column.
    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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from easystats/performance

All issues in easystats/performance

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.