mjskay / tidybayes

Bayesian analysis + tidy data + geoms (R package)
http://mjskay.github.io/tidybayes
GNU General Public License v3.0
710 stars 59 forks source link

`add_epred_draws` does not show error when `re_formula =` includes non-existent terms #317

Open mz555 opened 8 months ago

mz555 commented 8 months ago

I was using tidybayes to plot some data from a brms model, and realised the figure looked off, but could not tell why, until I realised the term I provided in add_epred_draws for re_formula= was misspelt.

It would be good if the package threw an error message to alert the user to this issue.

Wrong code: add_epred_draws(m1, re_formula = ~ (1 | item)) I used "item" with no capital. It showed no error when running the code, and only realised because my plot estimates were off.

Correct code: add_epred_draws(m1, re_formula = ~ (1 | Item))

Wrong plot image Correct plot image

mjskay commented 8 months ago

Yeah an error/warning here would be good. Can you check and see if you call the underlying brms function (brms::posterior_epred) no error/warning is generated? If that isn't generating a warning either then this is an issue for brms.