#| child: aaa.Rmd #| include: false
r descr_models("poisson_reg", "hurdle")
This engine has no tuning parameters.
r uses_extension("poisson_reg", "hurdle", "regression")
#| label: hurdle-reg library(poissonreg) poisson_reg() |> set_engine("hurdle") |> translate()
#| child: template-makes-dummies.Rmd
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:
#| include: false library(tidymodels)
#| message: false library(tidymodels) tidymodels_prefer() data("bioChemists", package = "pscl") poisson_reg() |> set_engine("hurdle") |> 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("hurdle") 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.
#| child: template-uses-case-weights.Rmd
#| label: predict-types parsnip:::get_from_env("poisson_reg_predict") |> dplyr::filter(engine == "hurdle") |> dplyr::select(mode, type)
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.