mjskay / tidybayes

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

linpred_draws fails with brms model #327

Open maxfarrell opened 1 month ago

maxfarrell commented 1 month ago

I am trying to use the function linpred_draws() on a brms model object:

   draws <- linpred_draws(
                  model,
                  newdata=model$data,
                  value = ".linpred",
                  ndraws = 4000,
                  seed = NULL,
                  re_formula = NULL,
                  category = ".category",
                  dpar = NULL) 

This was working in the past but now for simple models with no hierarhical effect I'm getting the following error:

Error in get_all_effects.brmsterms(x) : is.atomic(rsv_vars) is not TRUE

And for models with hierarchical effects I get the following error:

Errir in get_model_matrix(re$form[[i]], data: is.atomic(cols2remove) is not TRUE

I am using tidybayes version 3.0.6 and brms version 2.16.3

maxfarrell commented 1 month ago

Aftrer a little bit of researching and investigating my system, this function last worked in May 2024, but my system seems to have updated to R 4.4.1 (2024-06-14). This version seems to have a significant user-variable change (from https://cran.r-project.org/doc/manuals/r-release/NEWS.pdf):

CHANGES IN R 4.4.0 SIGNIFICANT USER-VISIBLE CHANGES: • is.atomic(NULL) now returns FALSE, as NULL is not an atomic vector. Strict back-compatibility would replace is.atomic(foo) by (is.null(foo) || is.atomic(foo)) but should happen only sparingly.