The warn_on_glm2 function causes an error for a stats::glm object where the method argument has been given a function. From the glm docs,
for the method argument:
the method to be used in fitting the model. The default method "glm.fit" uses iteratively reweighted least squares (IWLS): the alternative "model.frame" returns the model frame and does no fitting.
User-supplied fitting functions can be supplied either as a function or a character string naming a function, with a function which takes the same arguments as glm.fit. If specified as a character string it is looked up from within the stats namespace.
and the method vaue:
the name of the fitter function used (when provided as a character string to glm()) or the fitter function (when provided as that).
## Based on the example from the glm documentation
## Dobson (1990) Page 93: Randomized Controlled Trial :
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
glm.D93 <- glm(counts ~ outcome + treatment, family = poisson(),
method = glm.fit)
broom::tidy(glm.D93)
#> Error in x$method == "glm.fit2": comparison (1) is possible only for atomic and list types
This issue 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.
The problem
The
warn_on_glm2
function causes an error for astats::glm
object where the method argument has been given a function. From the glm docs, for the method argument:and the method vaue:
The trouble seems to be here, where we test equality between a function and a character. https://github.com/tidymodels/broom/blob/0f4c1caa8d7c3f7162849c3d892e522a913ed966/R/stats-glm-tidiers.R#L166
Reproducible example