This is an autoregressive classification model for epiprocess::epi_df data. It does "direct" forecasting, meaning that it estimates a class at a particular target horizon.
Usage
arx_classifier(
epi_data,
outcome,
predictors,
trainer = logistic_reg(),
args_list = arx_class_args_list()
)
Arguments
- epi_data
An
epi_df
object- outcome
A character (scalar) specifying the outcome (in the
epi_df
). Note that as witharx_forecaster()
, this is expected to be real-valued. Conversion of this data to unordered classes is handled internally based on thebreaks
argument toarx_class_args_list()
. If discrete classes are already in theepi_df
, it is recommended to code up a classifier from scratch usingepi_recipe()
.- predictors
A character vector giving column(s) of predictor variables. This defaults to the
outcome
. However, if manually specified, only those variables specifically mentioned will be used. (Theoutcome
will not be added.) By default, equals the outcome. If manually specified, does not add the outcome variable, so make sure to specify it.- trainer
A
{parsnip}
model describing the type of estimation. For now, we enforcemode = "classification"
. Typical values areparsnip::logistic_reg()
orparsnip::multinom_reg()
. More complicated trainers likeparsnip::naive_Bayes()
orparsnip::rand_forest()
can also be used.- args_list
A list of customization arguments to determine the type of forecasting model. See
arx_class_args_list()
.
Value
A list with (1) predictions
an epi_df
of predicted classes
and (2) epi_workflow
, a list that encapsulates the entire estimation
workflow
Examples
library(dplyr)
jhu <- case_death_rate_subset %>%
filter(time_value >= as.Date("2021-11-01"))
out <- arx_classifier(jhu, "death_rate", c("case_rate", "death_rate"))
out <- arx_classifier(
jhu,
"death_rate",
c("case_rate", "death_rate"),
trainer = parsnip::multinom_reg(),
args_list = arx_class_args_list(
breaks = c(-.05, .1), ahead = 14,
horizon = 14, method = "linear_reg"
)
)