butcher
butcher copied to clipboard
Add butcher support for multilevelmod / lme4
I am trying to use the butcher package to cut down on the size of fitted objects, in my case fits using lme4::lmer. That led me to parsnip, then here!
I would have thought this would work, but it doesn't.
library(multilevelmod)
#> Loading required package: parsnip
data(sleepstudy, package = "lme4")
mixed_model_spec <- linear_reg() %>% set_engine("lmer")
mixed_model_fit <-
mixed_model_spec %>%
fit(Reaction ~ Days + (Days | Subject), data = sleepstudy)
mixed_model_fit
Checking the size of the fits:
> object.size(mixed_model_fit)
67120 bytes
> object.size(butcher(mixed_model_fit))
67120 bytes
What am I missing?
Hi @bshor ! I think you don't see any changes because butcher does not have methods for models from lme4: The documentation for butcher says
The current axe methods have been tested on all parsnip model objects as listed here. If you are working with a new model object that could benefit from any kind of axing, we would love for you to make a pull request!
and your model is a not listed there, neither did I see anything in the butcher repo.
@DavisVaughan is that in scope for butcher?
Yes I think so!
Thanks! I had thought by using multilevelmod it would somehow automatically add lmer to the list. I may have to do it manually (never having done it before!).
I would be willing to help with this but would have to familiarize myself with the package - would need to do some careful tests to know which components could be removed with what loss of functionality.
That would be super helpful @bbolker! 🙌 This package has a vignette on how to add a new model, and I feel like the tests for GAMs are a pretty good example to look at.