business-science / anomalize

Tidy anomaly detection
https://business-science.github.io/anomalize/
338 stars 60 forks source link

What happens when trend is "2 weeks"? #61

Closed charlie-gallagher closed 3 years ago

charlie-gallagher commented 3 years ago

When decomposing data, you get a slew of warnings when you set "trend" to "2 weeks" (or N weeks). This is because lubridate::floor_date doesn't allow you to return multi-week floors. Instead it returns the closest week floor.

How does this affect time_decompose? Would it create spurious data?

library(tidyverse)
library(anomalize)

tidyverse_cran_downloads %>%
  time_decompose(count, method = "stl", frequency = "auto", trend = "2 weeks")
mdancho84 commented 3 years ago

This is a lubridate issue, where 2 weeks doesn't allow. It might be best to specify in days.