stats::glm()
uses maximum likelihood to fit a model for count data.
For this engine, there is a single mode: regression
This engine has no tuning parameters.
The poissonreg extension package is required to fit this model.
library(poissonreg)poisson_reg() %>%
set_engine("glm") %>%
translate()
## Poisson Regression Model Specification (regression)
##
## Computational engine: glm
##
## Model fit template:
## stats::glm(formula = missing_arg(), data = missing_arg(), weights = missing_arg(),
## family = stats::poisson)
Factor/categorical predictors need to be converted to numeric values
(e.g., dummy or indicator variables) for this engine. When using the
formula method via fit()
, parsnip will
convert factor columns to indicators.
This model can utilize case weights during model fitting. To use them,
see the documentation in case_weights and the examples
on tidymodels.org
.
The fit()
and fit_xy()
arguments have arguments called
case_weights
that expect vectors of case weights.
This model can utilize case weights during model fitting. To use them,
see the documentation in case_weights and the examples
on tidymodels.org
.
The fit()
and fit_xy()
arguments have arguments called
case_weights
that expect vectors of case weights.
However, the documentation in stats::glm()
assumes
that is specific type of case weights are being used:“Non-NULL weights
can be used to indicate that different observations have different
dispersions (with the values in weights being inversely proportional to
the dispersions); or equivalently, when the elements of weights are
positive integers w_i
, that each response y_i
is the mean of w_i
unit-weight observations. For a binomial GLM prior weights are used to
give the number of trials when the response is the proportion of
successes: they would rarely be used for a Poisson GLM.”
If frequency weights are being used in your application, the
glm_grouped()
model (and corresponding engine) may be
more appropriate.