Recompose bands separating anomalies from "normal" observations

time_recompose(data)

Arguments

data

A tibble or tbl_time object that has been processed with time_decompose() and anomalize().

Value

Returns a tbl_time object.

Details

The time_recompose() function is used to generate bands around the "normal" levels of observed values. The function uses the remainder_l1 and remainder_l2 levels produced during the anomalize() step and the season and trend/median_spans values from the time_decompose() step to reconstruct bands around the normal values.

The following key names are required: observed:remainder from the time_decompose() step and remainder_l1 and remainder_l2 from the anomalize() step.

See also

Time Series Anomaly Detection Functions (anomaly detection workflow):

Examples

library(dplyr) data(tidyverse_cran_downloads) # Basic Usage tidyverse_cran_downloads %>% time_decompose(count, method = "stl") %>% anomalize(remainder, method = "iqr") %>% time_recompose()
#> # A time tibble: 6,375 x 11 #> # Index: date #> # Groups: package [15] #> package date observed season trend remainder remainder_l1 remainder_l2 #> <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 broom 2017-01-01 1053. -1007. 1708. 352. -1725. 1704. #> 2 broom 2017-01-02 1481 340. 1731. -589. -1725. 1704. #> 3 broom 2017-01-03 1851 563. 1753. -465. -1725. 1704. #> 4 broom 2017-01-04 1947 526. 1775. -354. -1725. 1704. #> 5 broom 2017-01-05 1927 430. 1798. -301. -1725. 1704. #> 6 broom 2017-01-06 1948 136. 1820. -8.11 -1725. 1704. #> 7 broom 2017-01-07 1542 -988. 1842. 688. -1725. 1704. #> 8 broom 2017-01-08 1479. -1007. 1864. 622. -1725. 1704. #> 9 broom 2017-01-09 2057 340. 1887. -169. -1725. 1704. #> 10 broom 2017-01-10 2278 563. 1909. -194. -1725. 1704. #> # … with 6,365 more rows, and 3 more variables: anomaly <chr>, #> # recomposed_l1 <dbl>, recomposed_l2 <dbl>