Skip to content

Commit 991d70b

Browse files
authored
Merge pull request #364 from cmu-delphi/275-step_epi_slide
275 step epi slide
2 parents 63a520b + 740d438 commit 991d70b

11 files changed

+522
-6
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: epipredict
22
Title: Basic epidemiology forecasting methods
3-
Version: 0.0.17
3+
Version: 0.0.18
44
Authors@R: c(
55
person("Daniel", "McDonald", , "[email protected]", role = c("aut", "cre")),
66
person("Ryan", "Tibshirani", , "[email protected]", role = "aut"),

NAMESPACE

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ S3method(bake,check_enough_train_data)
2121
S3method(bake,epi_recipe)
2222
S3method(bake,step_epi_ahead)
2323
S3method(bake,step_epi_lag)
24+
S3method(bake,step_epi_slide)
2425
S3method(bake,step_growth_rate)
2526
S3method(bake,step_lag_difference)
2627
S3method(bake,step_population_scaling)
@@ -62,6 +63,7 @@ S3method(prep,check_enough_train_data)
6263
S3method(prep,epi_recipe)
6364
S3method(prep,step_epi_ahead)
6465
S3method(prep,step_epi_lag)
66+
S3method(prep,step_epi_slide)
6567
S3method(prep,step_growth_rate)
6668
S3method(prep,step_lag_difference)
6769
S3method(prep,step_population_scaling)
@@ -90,6 +92,7 @@ S3method(print,layer_threshold)
9092
S3method(print,layer_unnest)
9193
S3method(print,step_epi_ahead)
9294
S3method(print,step_epi_lag)
95+
S3method(print,step_epi_slide)
9396
S3method(print,step_growth_rate)
9497
S3method(print,step_lag_difference)
9598
S3method(print,step_naomit)
@@ -143,6 +146,7 @@ export(bake)
143146
export(cdc_baseline_args_list)
144147
export(cdc_baseline_forecaster)
145148
export(check_enough_train_data)
149+
export(clean_f_name)
146150
export(default_epi_recipe_blueprint)
147151
export(detect_layer)
148152
export(dist_quantiles)
@@ -194,6 +198,7 @@ export(smooth_quantile_reg)
194198
export(step_epi_ahead)
195199
export(step_epi_lag)
196200
export(step_epi_naomit)
201+
export(step_epi_slide)
197202
export(step_growth_rate)
198203
export(step_lag_difference)
199204
export(step_population_scaling)
@@ -221,10 +226,12 @@ importFrom(checkmate,assert_scalar)
221226
importFrom(cli,cli_abort)
222227
importFrom(dplyr,across)
223228
importFrom(dplyr,all_of)
229+
importFrom(dplyr,bind_cols)
224230
importFrom(dplyr,group_by)
225231
importFrom(dplyr,n)
226232
importFrom(dplyr,summarise)
227233
importFrom(dplyr,ungroup)
234+
importFrom(epiprocess,epi_slide)
228235
importFrom(epiprocess,growth_rate)
229236
importFrom(generics,augment)
230237
importFrom(generics,fit)
@@ -244,6 +251,8 @@ importFrom(rlang,":=")
244251
importFrom(rlang,abort)
245252
importFrom(rlang,as_function)
246253
importFrom(rlang,caller_env)
254+
importFrom(rlang,enquo)
255+
importFrom(rlang,enquos)
247256
importFrom(rlang,global_env)
248257
importFrom(rlang,inject)
249258
importFrom(rlang,is_logical)
@@ -262,6 +271,7 @@ importFrom(stats,qnorm)
262271
importFrom(stats,quantile)
263272
importFrom(stats,residuals)
264273
importFrom(tibble,tibble)
274+
importFrom(tidyr,crossing)
265275
importFrom(tidyr,drop_na)
266276
importFrom(vctrs,as_list_of)
267277
importFrom(vctrs,field)

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ Pre-1.0.0 numbering scheme: 0.x will indicate releases, while 0.0.x will indicat
5252
`...` args intended for `predict.model_fit()`
5353
- `bake.epi_recipe()` will now re-infer the geo and time type in case baking the
5454
steps has changed the appropriate values
55+
- Add `step_epi_slide` to produce generic sliding computations over an `epi_df`

R/epipredict-package.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## usethis namespace: start
22
#' @importFrom tibble tibble
33
#' @importFrom rlang := !! %||% as_function global_env set_names !!!
4-
#' @importFrom rlang is_logical is_true inject
4+
#' @importFrom rlang is_logical is_true inject enquo enquos
55
#' @importFrom stats poly predict lm residuals quantile
66
#' @importFrom cli cli_abort
77
#' @importFrom checkmate assert assert_character assert_int assert_scalar

R/get_test_data.R

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,18 @@ get_test_data <- function(
6565
i = "The following required columns are missing: {check$missing_names}"
6666
))
6767
}
68-
6968
if (class(forecast_date) != class(x$time_value)) {
7069
cli::cli_abort("`forecast_date` must be the same class as `x$time_value`.")
7170
}
72-
73-
7471
if (forecast_date < max(x$time_value)) {
7572
cli::cli_abort("`forecast_date` must be no earlier than `max(x$time_value)`")
7673
}
7774

7875
min_lags <- min(map_dbl(recipe$steps, ~ min(.x$lag %||% Inf)), Inf)
7976
max_lags <- max(map_dbl(recipe$steps, ~ max(.x$lag %||% 0)), 0)
8077
max_horizon <- max(map_dbl(recipe$steps, ~ max(.x$horizon %||% 0)), 0)
81-
min_required <- max_lags + max_horizon
78+
max_slide <- max(map_dbl(recipe$steps, ~ max(.x$before %||% 0)), 0)
79+
min_required <- max_lags + max_horizon + max_slide
8280
if (is.null(n_recent)) n_recent <- min_required + 1 # one extra for filling
8381
if (n_recent <= min_required) n_recent <- min_required + n_recent
8482

0 commit comments

Comments
 (0)