r descr_models("poisson_reg", "zeroinfl")
This engine has no tuning parameters.
r uses_extension("poisson_reg", "zeroinfl", "regression")
library(poissonreg) poisson_reg() %>% set_engine("zeroinfl") %>% translate()
For this particular model, a special formula is used to specify which columns affect the counts and which affect the model for the probability of zero counts. These sets of terms are separated by a bar. For example, y ~ x | z
. This type of formula is not used by the base R infrastructure (e.g. model.matrix()
)
When fitting a parsnip model with this engine directly, the formula method is required and the formula is just passed through. For example:
library(tidymodels)
library(tidymodels) tidymodels_prefer() data("bioChemists", package = "pscl") poisson_reg() %>% set_engine("zeroinfl") %>% fit(art ~ fem + mar | ment, data = bioChemists)
However, when using a workflow, the best approach is to avoid using [workflows::add_formula()] and use [workflows::add_variables()] in conjunction with a model formula:
data("bioChemists", package = "pscl") spec <- poisson_reg() %>% set_engine("zeroinfl") workflow() %>% add_variables(outcomes = c(art), predictors = c(fem, mar, ment)) %>% add_model(spec, formula = art ~ fem + mar | ment) %>% fit(data = bioChemists) %>% extract_fit_engine()
The reason for this is that [workflows::add_formula()] will try to create the model matrix and either fail or create dummy variables prematurely.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.