easystats / insight

:crystal_ball: Easy access to model information for various model objects
https://easystats.github.io/insight/
GNU General Public License v3.0
380 stars 38 forks source link

`find_variables()` & `brms`: Distributional component variables missing #896

Open vincentarelbundock opened 2 weeks ago

vincentarelbundock commented 2 weeks ago

The find_variables() function does not return predictors in the distributional component of a brms model. As a result, get_data() is missing some columns. In this example, the cyl variable should be included but is missing.

library(brms)
library(insight)
data("mtcars")

mdl <- 
  brm(
    bf(carb ~ gear * vs) + lf(disc ~ 0 + mo(cyl)),
    data = mtcars,
    family = cumulative("probit"),
    prior = set_prior("normal(0, 1)", class = "b") +
      set_prior("normal(0, 1)", dpar = "disc"),
  )

find_variables(mdl)
> $response
> [1] "carb"
> 
> $conditional
> [1] "gear" "vs"

get_data(mdl) |> head()
>                   carb gear vs
> Mazda RX4            4    4  0
> Mazda RX4 Wag        4    4  0
> Datsun 710           1    4  1
> Hornet 4 Drive       1    3  1
> Hornet Sportabout    2    3  0
> Valiant              1    3  1
strengejacke commented 1 week ago

brms is too flexible... 😞 But I have an idea how to fix this.