I am trying to fit a negative binomial regression to a time series using the trending package. When I try to calculate the confidence intervals and prediction intervals, I get the error message:
Error in
cbind()
: ! Not supported for tsibble. ℹ Please usedplyr::bind_cols()
instead.
Can someone please help?
Thanks
library(surveillance)
library(tidyverse)
library(tsibble)
library(forecast)
library(trending)
data(campyDE)
countsdf <- campyDE%>%
select(date, case)
countsdf$date <- as.Date(countsdf$date)
countsdf <- countsdf %>%
mutate(epiweek = yearweek(date, week_start = 1))
countsdf <- tsibble(countsdf, index = epiweek)
countsdf$fourier <- select(countsdf, epiweek, case) %>%
fourier(K = 1)
head(countsdf)
model <- glm_nb_model(
case ~
epiweek +
fourier)
fitted_model <- trending::fit(model, countsdf)
observed <- predict(fitted_model, simulate_pi = FALSE)