You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The underlying issue is that in broom.helpers:::model_get_n.glm()
` `` r
tcm <- model_compute_terms_contributions(model)
if (is.null(tcm)) {
return(NULL)
}
w <- model_get_weights(model)
the number of rows in `tcm` from `model_compute_terms_contributions()` reflects the original data.frame, whereas `w` reflects the size of the data.frame after subsetting.
``` r
nrow(mtcars) # original number of rows
#> [1] 32
nrow(mtcars[mtcars$mpg < 30, ]) # n rows after subsetting
#> [1] 28
mod <- glm(mpg ~ gear, data = mtcars, subset = mpg < 30)
broom.helpers:::model_compute_terms_contributions.default(mod) |>
nrow()
#> [1] 32 # original number
broom.helpers::model_get_weights(mod) |> length()
#> [1] 28 # correct
nrow(mod$model)
#> [1] 28
nrow(mod$data)
#> [1] 32
I'm getting a warning with
gtsummary::tbl_regression()
for a glm with a subset argument (initial bug report ddsjoberg/gtsummary/issues/2111)The problem is coming from
broom.helpers::tidy_plus_plus()
Created on 2024-12-23 with reprex v2.1.1
The underlying issue is that in
broom.helpers:::model_get_n.glm()
` `` r
tcm <- model_compute_terms_contributions(model)
if (is.null(tcm)) {
return(NULL)
}
w <- model_get_weights(model)
Created on 2024-12-23 with reprex v2.1.1
broom.helpers:::model_compute_terms_contributions.default()
is using model$data, perhaps it should be using model$modelEverything works as expected with a
lm()
model with the subset argument (I've not tried other models).The text was updated successfully, but these errors were encountered: