Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Daily time series with zeros #11
I have an issue that I'm having trouble debugging, I'm not convinced its a bug, but thought that I should post it here anyway. I have a fair number (10+) of daily time series that I'm using as control series. Some of the time-series contain 0 entries when daily. When I run the model using daily time series I get the following error message:
I've tried dropping out control time series one by one without luck.
When I convert the same time series to weekly, most (but not all) of the zero entries are removed and the model runs without any problems.
I'm at a bit of a loss as to why this error is occurring. I'm using the latest version of the package.
Actually I encountered the same problem as @lmkirvan , see the reproducible example below
I'm not really sure if the issue is caused by the 0s, though.
Thanks for sharing the reproducible example.
The problem is caused by the fact that the times are irregular:
shows the granularity is mostly hourly, but there is one 2-hour gap.
No fix ready yet (working on it), but as a workaround, you can regularize the time series before fitting the model:
times <- seq(start(ts), end(ts), by = "hour") ts.regularized <- merge(ts, zoo(, times), all = TRUE) diff(time(ts.regularized))
Now that the granularity is always 1 hour (having value
impact <- CausalImpact(ts.regularized, pre.period, post.period, model.args = list(niter = 5000, nseasons = 24))