smooth_incidence | R Documentation |
Smooth a time series of noisy observations.
Currently only LOESS smoothing (smoothing_method = "LOESS"
) is implemented.
smooth_incidence(
incidence_data,
smoothing_method = "LOESS",
simplify_output = TRUE,
...
)
incidence_data |
An object containing incidence data through time. It can either be:
|
smoothing_method |
string. Method used to smooth the original incidence data. Available options are:
|
simplify_output |
boolean. Return a numeric vector instead of module output object if output offset is zero? |
... |
Arguments passed on to
|
A list with two elements:
A numeric vector named values
: the result of the computations on the input data.
An integer named index_offset
: the offset, counted in number of time steps,
by which the result is shifted compared to an index_offset
of 0
.
This parameter allows one to keep track of the date of the first value in values
without needing to carry a date
column around.
A positive offset means values
are delayed in the future compared to the reference values.
A negative offset means the opposite.
Note that the index_offset
of the output of the function call
accounts for the (optional) index_offset
of the input.
If index_offset
is 0
and simplify_output = TRUE
,
the index_offset
is dropped and the values
element is returned as a numeric vector.
## Basic usage of smooth_incidence
smoothed_incidence_1 <- smooth_incidence(
incidence_data = HK_incidence_data$case_incidence,
smoothing_method = "LOESS"
)
## Advanced usage of smooth_incidence
# Smoothing the incidence using a LOESS window of 15 days, fitting polynomials
# of degree 2 in the LOESS algorithm, and averaging the initial Re estimate over
# the first 7 days.
smoothed_incidence_2 <- smooth_incidence(
incidence_data = HK_incidence_data$case_incidence,
smoothing_method = "LOESS",
simplify_output = FALSE,
data_points_incl = 15,
degree = 2,
initial_Re_estimate_window = 7
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.