| rpart_exposure | R Documentation |
This function is a wrapper around rpart::rpart() for Poisson regression
trees using weighted exposures (observation times).
rpart_exposure(
formula,
data,
exposure_col = "exposure",
weights = NULL,
control,
cost,
shrink = 1,
...
)
formula |
A model formula that contains a single response variable on the left-hand side. |
data |
Optional. A data frame containing variables used in the model. |
exposure_col |
Character string. The name of a column in |
weights |
Optional weights to use in the fitting process. |
control |
A list of hyperparameters. See |
cost |
A vector of non-negative costs for each variable in the model. |
shrink |
Optional parameter for the splitting function. Coefficient of variation of the prior distribution. |
... |
Alternative input for arguments passed to
|
Outside of the tidymodels ecosystem, rpart_exposure() has no
advantages over rpart::rpart() since that function allows for exposures to
be specified in the formula interface by passing cbind(exposure, y) as a
response variable.
Within tidymodels, rpart_exposure() provides an advantage because
it will ensure that exposures are included in the data whenever resamples are
created.
The formula, data, weights, control, and cost arguments have the
same meanings as rpart::rpart(). shrink is passed to rpart::rpart()'s
parms argument via a named list. See that function's documentation for full
details.
An rpart model
rpart::rpart()
if (interactive()) {
rpart_exposure(deaths ~ age_group + gender, us_deaths,
exposure_col = "population")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.