33
33
# ' out <- arx_forecaster(jhu, "death_rate",
34
34
# ' c("case_rate", "death_rate"),
35
35
# ' trainer = quantile_reg(),
36
- # ' args_list = arx_args_list(levels = 1:9 / 10)
36
+ # ' args_list = arx_args_list(quantile_levels = 1:9 / 10)
37
37
# ' )
38
38
arx_forecaster <- function (epi_data ,
39
39
outcome ,
@@ -99,7 +99,7 @@ arx_forecaster <- function(epi_data,
99
99
# ' arx_fcast_epi_workflow(jhu, "death_rate",
100
100
# ' c("case_rate", "death_rate"),
101
101
# ' trainer = quantile_reg(),
102
- # ' args_list = arx_args_list(levels = 1:9 / 10)
102
+ # ' args_list = arx_args_list(quantile_levels = 1:9 / 10)
103
103
# ' )
104
104
arx_fcast_epi_workflow <- function (
105
105
epi_data ,
@@ -134,18 +134,20 @@ arx_fcast_epi_workflow <- function(
134
134
# --- postprocessor
135
135
f <- frosting() %> % layer_predict() # %>% layer_naomit()
136
136
if (inherits(trainer , " quantile_reg" )) {
137
- # add all levels to the forecaster and update postprocessor
138
- tau <- sort(compare_quantile_args(
139
- args_list $ levels ,
140
- rlang :: eval_tidy(trainer $ args $ tau )
137
+ # add all quantile_level to the forecaster and update postprocessor
138
+ quantile_levels <- sort(compare_quantile_args(
139
+ args_list $ quantile_levels ,
140
+ rlang :: eval_tidy(trainer $ args $ quantile_levels )
141
141
))
142
- args_list $ levels <- tau
143
- trainer $ args $ tau <- rlang :: enquo(tau )
144
- f <- layer_quantile_distn(f , levels = tau ) %> % layer_point_from_distn()
142
+ args_list $ quantile_levels <- quantile_levels
143
+ trainer $ args $ quantile_levels <- rlang :: enquo(quantile_levels )
144
+ f <- layer_quantile_distn(f , quantile_levels = quantile_levels ) %> %
145
+ layer_point_from_distn()
145
146
} else {
146
147
f <- layer_residual_quantiles(
147
148
f ,
148
- probs = args_list $ levels , symmetrize = args_list $ symmetrize ,
149
+ quantile_levels = args_list $ quantile_levels ,
150
+ symmetrize = args_list $ symmetrize ,
149
151
by_key = args_list $ quantile_by_key
150
152
)
151
153
}
@@ -173,7 +175,7 @@ arx_fcast_epi_workflow <- function(
173
175
# ' The default `NULL` will attempt to determine this automatically.
174
176
# ' @param target_date Date. The date for which the forecast is intended.
175
177
# ' The default `NULL` will attempt to determine this automatically.
176
- # ' @param levels Vector or `NULL`. A vector of probabilities to produce
178
+ # ' @param quantile_levels Vector or `NULL`. A vector of probabilities to produce
177
179
# ' prediction intervals. These are created by computing the quantiles of
178
180
# ' training residuals. A `NULL` value will result in point forecasts only.
179
181
# ' @param symmetrize Logical. The default `TRUE` calculates
@@ -197,6 +199,7 @@ arx_fcast_epi_workflow <- function(
197
199
# ' create a prediction. For this reason, setting `nafill_buffer < min(lags)`
198
200
# ' will be treated as _additional_ allowed recent data rather than the
199
201
# ' total amount of recent data to examine.
202
+ # ' @param ... Space to handle future expansions (unused).
200
203
# '
201
204
# '
202
205
# ' @return A list containing updated parameter choices with class `arx_flist`.
@@ -205,18 +208,19 @@ arx_fcast_epi_workflow <- function(
205
208
# ' @examples
206
209
# ' arx_args_list()
207
210
# ' arx_args_list(symmetrize = FALSE)
208
- # ' arx_args_list(levels = c(.1, .3, .7, .9), n_training = 120)
211
+ # ' arx_args_list(quantile_levels = c(.1, .3, .7, .9), n_training = 120)
209
212
arx_args_list <- function (
210
213
lags = c(0L , 7L , 14L ),
211
214
ahead = 7L ,
212
215
n_training = Inf ,
213
216
forecast_date = NULL ,
214
217
target_date = NULL ,
215
- levels = c(0.05 , 0.95 ),
218
+ quantile_levels = c(0.05 , 0.95 ),
216
219
symmetrize = TRUE ,
217
220
nonneg = TRUE ,
218
221
quantile_by_key = character (0L ),
219
- nafill_buffer = Inf ) {
222
+ nafill_buffer = Inf ,
223
+ ... ) {
220
224
# error checking if lags is a list
221
225
.lags <- lags
222
226
if (is.list(lags )) lags <- unlist(lags )
@@ -227,7 +231,7 @@ arx_args_list <- function(
227
231
arg_is_date(forecast_date , target_date , allow_null = TRUE )
228
232
arg_is_nonneg_int(ahead , lags )
229
233
arg_is_lgl(symmetrize , nonneg )
230
- arg_is_probabilities(levels , allow_null = TRUE )
234
+ arg_is_probabilities(quantile_levels , allow_null = TRUE )
231
235
arg_is_pos(n_training )
232
236
if (is.finite(n_training )) arg_is_pos_int(n_training )
233
237
if (is.finite(nafill_buffer )) arg_is_pos_int(nafill_buffer , allow_null = TRUE )
@@ -238,7 +242,7 @@ arx_args_list <- function(
238
242
lags = .lags ,
239
243
ahead ,
240
244
n_training ,
241
- levels ,
245
+ quantile_levels ,
242
246
forecast_date ,
243
247
target_date ,
244
248
symmetrize ,
@@ -259,8 +263,8 @@ print.arx_fcast <- function(x, ...) {
259
263
}
260
264
261
265
compare_quantile_args <- function (alist , tlist ) {
262
- default_alist <- eval(formals(arx_args_list )$ levels )
263
- default_tlist <- eval(formals(quantile_reg )$ tau )
266
+ default_alist <- eval(formals(arx_args_list )$ quantile_level )
267
+ default_tlist <- eval(formals(quantile_reg )$ quantile_level )
264
268
if (setequal(alist , default_alist )) {
265
269
if (setequal(tlist , default_tlist )) {
266
270
return (sort(unique(union(alist , tlist ))))
0 commit comments