| impute_anomalies | R Documentation |
Runs detect_anomalies(), replaces flagged points with NA, and
re-interpolates with the same fill idiom used throughout this package
(zoo::na.approx(), remaining edge NAs filled with the series mean) –
a cleaned series to fit on instead of the raw one, so a handful of
spikes/dips don't distort the fitted model the way they would
untouched. Distinct from decompose_series()'s robust argument, which
downweights outliers during decomposition rather than removing them
before fitting; the two can be used independently or together.
impute_anomalies(
df,
date_agg = "day",
method = c("iqr", "zscore"),
threshold = 1.5
)
df |
A tibble with |
date_agg |
Aggregation frequency: one of |
method |
|
threshold |
Numeric sensitivity threshold, passed through to
|
A tibble with columns ds, y (the cleaned series). The count
of points that were flagged and replaced is attached as
attr(result, "n_imputed").
df <- tibble::tibble(ds = as.Date("2024-01-01") + 0:29, y = c(rep(10, 29), 100))
impute_anomalies(df, date_agg = "day", method = "iqr")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.