needs(prophet)
wl_df_pr <- wl_df |>
select(ds = mo,
y = x92nd_percentile_weeks) |>
mutate(y = as.numeric(y))
m <- prophet(wl_df_pr)
fut <- make_future_dataframe(m, periods = 13)
forecast <- predict(m, fut)
forecast_aug <- forecast |>
left_join(wl_df, by = c("ds" = "mo")) |>
mutate(estimated_number_of_unique_patients_mil = as.numeric(estimated_number_of_unique_patients_mil))
plot(m, forecast) + prophet::add_changepoints_to_plot(m, threshold = 0.05) +
#geom_line(data = forecast_aug, aes(ds, estimated_number_of_unique_patients_mil), colour = "blue") +
geom_vline(xintercept = c(as.POSIXct("2010-05-06"), as.POSIXct("2015-05-07"), as.POSIXct("2017-06-08"), as.POSIXct("2019-12-09"), as.POSIXct("2020-03-23"))) +
geom_vline(xintercept = as.POSIXct("2023-12-20"), colour = "green") +
ggthemes::theme_economist() +
scale_y_continuous(position = "right",
label = scales::number)