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

Add butchering methods for glm() #212

Merged
merged 7 commits into from
Mar 18, 2022
Merged

Add butchering methods for glm() #212

merged 7 commits into from
Mar 18, 2022

Conversation

juliasilge
Copy link
Member

Closes #211

library(butcher)

more_cars <- mtcars[rep(1:32, each = 1000),]
cars_glm <- glm(mpg ~ ., data = more_cars)
weigh(cars_glm)
#> # A tibble: 63 × 2
#>    object             size
#>    <chr>             <dbl>
#>  1 qr.qr             5.36 
#>  2 y                 2.80 
#>  3 residuals         2.80 
#>  4 fitted.values     2.80 
#>  5 linear.predictors 2.80 
#>  6 weights           2.80 
#>  7 prior.weights     2.80 
#>  8 effects           0.513
#>  9 model.mpg         0.256
#> 10 model.cyl         0.256
#> # … with 53 more rows

butchered <- butcher(cars_glm)
sum(weigh(cars_glm)$size)
#> [1] 28.325
sum(weigh(butchered)$size)
#> [1] 11.75713
weigh(butchered)
#> # A tibble: 53 × 2
#>    object             size
#>    <chr>             <dbl>
#>  1 linear.predictors 2.80 
#>  2 weights           2.80 
#>  3 prior.weights     2.80 
#>  4 effects           0.513
#>  5 model.mpg         0.256
#>  6 model.cyl         0.256
#>  7 model.disp        0.256
#>  8 model.hp          0.256
#>  9 model.drat        0.256
#> 10 model.wt          0.256
#> # … with 43 more rows

Created on 2022-02-08 by the reprex package (v2.0.1)

As far as I can tell, the linear.predictors and weights components are needed to make a prediction but it's very possible I missed something.

@juliasilge
Copy link
Member Author

The older versions of R are failing because of randomForest. We'll have to figure out what to do about that.

@juliasilge juliasilge requested a review from DavisVaughan March 17, 2022 20:27
@juliasilge juliasilge merged commit 77b3b44 into main Mar 18, 2022
@juliasilge juliasilge deleted the add-glm branch March 18, 2022 18:48
@github-actions
Copy link

github-actions bot commented Apr 2, 2022

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add methods for glm()
2 participants