View source: R/step_training_window.R
step_training_window | R Documentation |
step_training_window
creates a specification of a recipe step that
limits the size of the training window to the n_recent
most recent
observations in time_value
per group, where the groups are formed
based on the remaining epi_keys
.
step_training_window(
recipe,
role = NA,
n_recent = 50,
epi_keys = NULL,
id = rand_id("training_window")
)
recipe |
A recipe object. The step will be added to the sequence of operations for this recipe. |
role |
For model terms created by this step, what analysis role should
they be assigned? |
n_recent |
An integer value that represents the number of most recent observations that are to be kept in the training window per key The default value is 50. |
epi_keys |
An optional character vector for specifying "key" variables
to group on. The default, |
id |
A unique identifier for the step |
Note that step_epi_lead()
and step_epi_lag()
should come
after any filtering step.
An updated version of recipe
with the new step added to the
sequence of any existing operations.
tib <- tibble(
x = 1:10,
y = 1:10,
time_value = rep(seq(as.Date("2020-01-01"), by = 1, length.out = 5), 2),
geo_value = rep(c("ca", "hi"), each = 5)
) %>%
as_epi_df()
epi_recipe(y ~ x, data = tib) %>%
step_training_window(n_recent = 3) %>%
prep(tib) %>%
bake(new_data = NULL)
epi_recipe(y ~ x, data = tib) %>%
step_epi_naomit() %>%
step_training_window(n_recent = 3) %>%
prep(tib) %>%
bake(new_data = NULL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.