Skip to content

Commit 45dde20

Browse files
committed
refactor: update arx_forecaster predictor arg #298
1 parent 944a562 commit 45dde20

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

NEWS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ Pre-1.0.0 numbering scheme: 0.x will indicate releases, while 0.0.x will indicat
44

55
# epipredict 0.1
66

7+
- the `predictor` argument in `arx_forecaster()` now defaults to the value of the `outcome` argument
78
- `*_args_list()` functions now warn if `forecast_date + ahead != target_date`
89
- `layer_residual_quantiles()` will now error if any of the residual quantiles are NA
9-
- add `check_enough_train_data` that will error if training data is too small
10-
- added `check_enough_train_data` to `arx_forecaster`
10+
- add `check_enough_train_data()` that will error if training data is too small
11+
- added `check_enough_train_data()` to `arx_forecaster()`
1112
- simplify `layer_residual_quantiles()` to avoid timesuck in `utils::methods()`
1213
- rename the `dist_quantiles()` to be more descriptive, breaking change
1314
- removes previous `pivot_quantiles()` (now `*_wider()`, breaking change)

R/arx_forecaster.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
#' @param epi_data An `epi_df` object
99
#' @param outcome A character (scalar) specifying the outcome (in the
1010
#' `epi_df`).
11-
#' @param predictors A character vector giving column(s) of predictor
12-
#' variables.
11+
#' @param predictors A character vector giving column(s) of predictor variables.
12+
#' This defaults to the `outcome`. However, if manually specified, only those variables
13+
#' specifically mentioned will be used. (The `outcome` will not be added.)
14+
#' By default, equals the outcome. If manually specified, does not add the
15+
#' outcome variable, so make sure to specify it.
1316
#' @param trainer A `{parsnip}` model describing the type of estimation.
1417
#' For now, we enforce `mode = "regression"`.
1518
#' @param args_list A list of customization arguments to determine
@@ -37,7 +40,7 @@
3740
#' )
3841
arx_forecaster <- function(epi_data,
3942
outcome,
40-
predictors,
43+
predictors = outcome,
4144
trainer = parsnip::linear_reg(),
4245
args_list = arx_args_list()) {
4346
if (!is_regression(trainer)) {
@@ -104,7 +107,7 @@ arx_forecaster <- function(epi_data,
104107
arx_fcast_epi_workflow <- function(
105108
epi_data,
106109
outcome,
107-
predictors,
110+
predictors = outcome,
108111
trainer = NULL,
109112
args_list = arx_args_list()) {
110113
# --- validation

R/canned-epipred.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ validate_forecaster_inputs <- function(epi_data, outcome, predictors) {
55
"!" = "This one is a {.cls {class(epi_data)}}."
66
))
77
}
8-
arg_is_chr(predictors)
98
arg_is_chr_scalar(outcome)
9+
arg_is_chr(predictors)
1010
if (!outcome %in% names(epi_data)) {
1111
cli::cli_abort("{.var {outcome}} was not found in the training data.")
1212
}

0 commit comments

Comments
 (0)