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 tidyr 2017-01-01 873. -2761. 5053. -1418. -3748. 3708. #> 2 tidyr 2017-01-02 1840. 901. 5047. -4108. -3748. 3708. #> 3 tidyr 2017-01-03 2495. 1460. 5041. -4006. -3748. 3708. #> 4 tidyr 2017-01-04 2906. 1430. 5035. -3559. -3748. 3708. #> 5 tidyr 2017-01-05 2847. 1239. 5029. -3421. -3748. 3708. #> 6 tidyr 2017-01-06 2756. 367. 5024. -2635. -3748. 3708. #> 7 tidyr 2017-01-07 1439. -2635. 5018. -944. -3748. 3708. #> 8 tidyr 2017-01-08 1556. -2761. 5012. -695. -3748. 3708. #> 9 tidyr 2017-01-09 3678. 901. 5006. -2229. -3748. 3708. #> 10 tidyr 2017-01-10 7086. 1460. 5000. 626. -3748. 3708. #> # ... with 6,365 more rows, and 3 more variables: anomaly <chr>, #> # recomposed_l1 <dbl>, recomposed_l2 <dbl>