Struggling with add_epred_draws() on model with measurement error term

Hi!

Not sure if this is a limitation or a special case where proceeding is un-intuitive:
In models with measurement error term, tidybayes::add_epred_draws() throws an error:

library(brms)
library(modelr)
library(tidybayes)

d = data.frame(con = rep(1:5, each = 6),
               cat = rep(letters[1:2], each =3),
               res = abs(rnorm(30,100,25)),
               err = abs(rnorm(30)))

m = brm(bf(res | mi(err) ~ 1 + con + cat + con:cat),
        chains = 1,
        iter = 1000,
        data = d)
summary(m)
plot(conditional_effects(m), ask = FALSE) # not an issue for the built-in brms function

d %>%
  group_by(cat) %>% 
  data_grid(con = seq_range(con, n = 101)) %>%
  add_epred_draws(m) %>%
  ggplot(aes(x = con, y = res, color = cat)) +
  stat_lineribbon(aes(y = .epred))

Error: The following variables can neither be found in 'data' nor in 'data2': 'err'

Is there a way around this?

  • Operating System: Windows 10
  • brms Version: 2.18.0
  • tidybayes Version: 3.0.3