business-science / anomalize

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

time_decompose with missing values #21

Open cdeterman opened 6 years ago

cdeterman commented 6 years ago

My dataset is much larger but this error is trivially reproduced with the following sample data.

tmp <- structure(list(ds = structure(c(16482, 16483, 16484, 16485, 16486, 
16487), class = "Date"), y = c(2.16618784530387, NA, NA, 1.95971962616822, 
NA, NA)), .Names = c("ds", "y"), row.names = c(NA, -6L), class = c("tbl_df", 
"tbl", "data.frame"))

Obviously there are NA values. I have been using the prophet package to build some forecast models which handles NA values without an issue. There are likely outliers in my datasets that I would like to leverage anomalize. However, there are various NA values that cause an error to be through with the first time_decompose function. For example

tmp %>%
  time_decompose(y)

Converting from tbl_df to tbl_time. Auto-index message: index = ds frequency = 1 days trend = 6 days Error in na.fail.default(as.ts(x)) : missing values in object

Thoughts on how to address this?

srgorelik commented 1 year ago

I've been having the same problem. Has anyone found a solution?