Skip to content

Add butchering methods for glm() - #212

Merged
juliasilge merged 7 commits into
mainfrom
add-glm
Mar 18, 2022
Merged

juliasilge merged 7 commits into
mainfrom
add-glm

Conversation

@juliasilge

Copy link
Copy Markdown
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
Copy Markdown
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
Comment thread R/glm.R Outdated
Comment thread R/glm.R Outdated
@juliasilge
juliasilge merged commit 77b3b44 into main Mar 18, 2022
@juliasilge
juliasilge deleted the add-glm branch March 18, 2022 18:48
@github-actions

github-actions Bot commented Apr 2, 2022

Copy link
Copy Markdown
Contributor

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