bbolker / broom.mixed

tidy methods for mixed models in R
229 stars 23 forks source link

`glance.brmsfit` without group effects does not work despite commit cd22fbd #101

Closed vincentarelbundock closed 4 years ago

vincentarelbundock commented 4 years ago

This issue was first noted by @andrewheiss on Twitter.

A recent commit allowed tidy.brmsfit to work with models without group effects: https://github.com/bbolker/broom.mixed/commit/cd22fbd652fed8b8661e7fcbbe5cfcbdd79a8143

Unfortunately, glance.brmsfit still does not work in github master as of https://github.com/bbolker/broom.mixed/commit/3d120888ccc54bf71518b83512d741264e3c351c

library(brms)
library(broom.mixed)
dat <- ggplot2::mpg

mod <- brm(cty ~ displ + drv, data=dat)

broom.mixed:::glance.brmsfit(mod)
#> Error: No group-level effects detected. Call method 'fixef' to access population-level effects.

The sigma function from stats is called by glance_stan when it is fed a brmsfit object, but it produces the same error:

stats::sigma(mod)

In turn, stats::sigma seems to trigger this method, which again produces the same error message:

rstanarm::sigma(mod)

Do you have a sense of what the best strategy to fix this would be?

Thanks!

bbolker commented 4 years ago

This should be fixed in 88ff386d; feel free to re-install and check. The problem was that there wasn't a sigma.brmsfit method, so the sigma call fell through to sigma.default(), which is bogus but produces a harmless NULL rather than an error when the model has random effects ...

vincentarelbundock commented 4 years ago

Works great! Thanks a lot of the super quick fix!