Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

275 step epi slide #364

Merged
merged 12 commits into from
Aug 3, 2024
Merged
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: epipredict
Title: Basic epidemiology forecasting methods
Version: 0.0.17
Version: 0.0.18
Authors@R: c(
person("Daniel", "McDonald", , "[email protected]", role = c("aut", "cre")),
person("Ryan", "Tibshirani", , "[email protected]", role = "aut"),
Expand Down
10 changes: 10 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ S3method(bake,check_enough_train_data)
S3method(bake,epi_recipe)
S3method(bake,step_epi_ahead)
S3method(bake,step_epi_lag)
S3method(bake,step_epi_slide)
S3method(bake,step_growth_rate)
S3method(bake,step_lag_difference)
S3method(bake,step_population_scaling)
Expand Down Expand Up @@ -62,6 +63,7 @@ S3method(prep,check_enough_train_data)
S3method(prep,epi_recipe)
S3method(prep,step_epi_ahead)
S3method(prep,step_epi_lag)
S3method(prep,step_epi_slide)
S3method(prep,step_growth_rate)
S3method(prep,step_lag_difference)
S3method(prep,step_population_scaling)
Expand Down Expand Up @@ -90,6 +92,7 @@ S3method(print,layer_threshold)
S3method(print,layer_unnest)
S3method(print,step_epi_ahead)
S3method(print,step_epi_lag)
S3method(print,step_epi_slide)
S3method(print,step_growth_rate)
S3method(print,step_lag_difference)
S3method(print,step_naomit)
Expand Down Expand Up @@ -143,6 +146,7 @@ export(bake)
export(cdc_baseline_args_list)
export(cdc_baseline_forecaster)
export(check_enough_train_data)
export(clean_f_name)
export(default_epi_recipe_blueprint)
export(detect_layer)
export(dist_quantiles)
Expand Down Expand Up @@ -194,6 +198,7 @@ export(smooth_quantile_reg)
export(step_epi_ahead)
export(step_epi_lag)
export(step_epi_naomit)
export(step_epi_slide)
export(step_growth_rate)
export(step_lag_difference)
export(step_population_scaling)
Expand Down Expand Up @@ -221,10 +226,12 @@ importFrom(checkmate,assert_scalar)
importFrom(cli,cli_abort)
importFrom(dplyr,across)
importFrom(dplyr,all_of)
importFrom(dplyr,bind_cols)
importFrom(dplyr,group_by)
importFrom(dplyr,n)
importFrom(dplyr,summarise)
importFrom(dplyr,ungroup)
importFrom(epiprocess,epi_slide)
importFrom(epiprocess,growth_rate)
importFrom(generics,augment)
importFrom(generics,fit)
Expand All @@ -244,6 +251,8 @@ importFrom(rlang,":=")
importFrom(rlang,abort)
importFrom(rlang,as_function)
importFrom(rlang,caller_env)
importFrom(rlang,enquo)
importFrom(rlang,enquos)
importFrom(rlang,global_env)
importFrom(rlang,inject)
importFrom(rlang,is_logical)
Expand All @@ -262,6 +271,7 @@ importFrom(stats,qnorm)
importFrom(stats,quantile)
importFrom(stats,residuals)
importFrom(tibble,tibble)
importFrom(tidyr,crossing)
importFrom(tidyr,drop_na)
importFrom(vctrs,as_list_of)
importFrom(vctrs,field)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ Pre-1.0.0 numbering scheme: 0.x will indicate releases, while 0.0.x will indicat
`...` args intended for `predict.model_fit()`
- `bake.epi_recipe()` will now re-infer the geo and time type in case baking the
steps has changed the appropriate values
- Add `step_epi_slide` to produce generic sliding computations over an `epi_df`
2 changes: 1 addition & 1 deletion R/epipredict-package.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## usethis namespace: start
#' @importFrom tibble tibble
#' @importFrom rlang := !! %||% as_function global_env set_names !!!
#' @importFrom rlang is_logical is_true inject
#' @importFrom rlang is_logical is_true inject enquo enquos
#' @importFrom stats poly predict lm residuals quantile
#' @importFrom cli cli_abort
#' @importFrom checkmate assert assert_character assert_int assert_scalar
Expand Down
6 changes: 2 additions & 4 deletions R/get_test_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,18 @@ get_test_data <- function(
i = "The following required columns are missing: {check$missing_names}"
))
}

if (class(forecast_date) != class(x$time_value)) {
cli::cli_abort("`forecast_date` must be the same class as `x$time_value`.")
}


if (forecast_date < max(x$time_value)) {
cli::cli_abort("`forecast_date` must be no earlier than `max(x$time_value)`")
}

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

Expand Down
Loading
Loading