View source: R/step_growth_rate.R
step_growth_rate | R Documentation |
step_growth_rate()
creates a specification of a recipe step
that will generate one or more new columns of derived data.
step_growth_rate(
recipe,
...,
role = "predictor",
horizon = 7,
method = c("rel_change", "linear_reg"),
log_scale = FALSE,
na_rm = TRUE,
replace_Inf = NA,
prefix = "gr_",
skip = FALSE,
id = rand_id("growth_rate")
)
recipe |
A recipe object. The step will be added to the sequence of operations for this recipe. |
... |
One or more selector functions to choose variables
for this step. See |
role |
For model terms created by this step, what analysis role should
they be assigned? |
horizon |
Bandwidth for the sliding window, when |
method |
Either "rel_change" or "linear_reg",
indicating the method to use for the growth rate
calculation. These are local methods: they are run in a sliding
fashion over the sequence (in order to estimate derivatives and hence
growth rates). See |
log_scale |
Should growth rates be estimated using the parameterization
on the log scale? See details for an explanation. Default is |
na_rm |
Should missing values be removed before the computation? Default
is |
replace_Inf |
Sometimes, the growth rate calculation can result in
infinite values (if the denominator is zero, for example). In this case,
most prediction methods will fail. This argument specifies potential
replacement values. The default ( |
prefix |
A character string that will be prefixed to the new column. |
skip |
A logical. Should the step be skipped when the
recipe is baked by |
id |
A unique identifier for the step |
An updated version of recipe
with the new step added to the
sequence of any existing operations.
Other row operation steps:
step_adjust_latency()
,
step_epi_lag()
,
step_lag_difference()
tiny_geos <- c("as", "mp", "vi", "gu", "pr")
rates <- covid_case_death_rates %>%
filter(time_value >= as.Date("2021-11-01"), !(geo_value %in% tiny_geos))
r <- epi_recipe(rates) %>%
step_growth_rate(case_rate, death_rate)
r
r %>%
prep(rates) %>%
bake(new_data = NULL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.