Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tidy.brmsfit fails on distributional models #138

Open
chrishanretty opened this issue Jan 10, 2023 · 0 comments
Open

tidy.brmsfit fails on distributional models #138

chrishanretty opened this issue Jan 10, 2023 · 0 comments

Comments

@chrishanretty
Copy link

brms allows users to model the residual standard deviation. tidy.brmsfit gives an error with such models. A MWE follows:

library(brms)
library(broom.mixed)
library(lme4)

### Let's repeat a model from lme4
fm1 <- brm(angle ~ recipe * temperature + (1|recipe) + (1|recipe:replicate),
           data = cake,
           cores = 4,
           chains = 4)

### WORKS
tfm1 <- tidy(fm1)

### Complicate by adding heteroskedasticity
fm2 <- brm(bf(angle ~ recipe * temperature + (1|recipe) + (1|recipe:replicate),
              sigma ~ recipe),
           data = cake,
           cores = 4,
           chains = 4)

### DOESN'T WORK
tfm2 <- tidy(fm2)

The problem arises because the regular expression which identifies random effects uses the term "sigma". Here, "sigma" is present, but not because it identifies a random effect, but because it's the outcome in an auxiliary regression.

I think the issue can be resolved by dropping in the following code (or something equivalent) in just after line 227 in the code:

res_list$ran_pars <- res_list$ran_pars |>
 subset(group != "Residual")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant