I am trying to forecast the mean of a month of daily time series data. I need to forecast the mean of the current month (meaning we have partial data) as well as the next month(s) (meaning I need to forecast the path of the daily time series throughout this month and the next month).
Using the modern forecast package and techniques from Hyndman's FPP3, it is straightforward to forecast the daily. It would then be straightforward, with some data manipulation, to calculate the forecasted mean of the month from the forecasted daily observations.
But, from what I understand, doing it this way forces you to go outside the bounds of the forecast package, and thus you miss out on being able to model and forecast the actual monthly mean directly using the scenarios feature as well as being able to forecast the monthly mean with prediction intervals.
My aim is to be able to re-forecast the monthly every day as the new daily observation comes in, and have the uncertainty / prediction interval around monthly mean forecast start to decrease as we approach the end of the month.
I've cooked up the following repro to demonstrate what I'm getting at.
# cross validated question library(fpp3) library(lubridate) library(tidyverse) repro_data <- tsibble(date = as_date(ymd("2023-06-01"):ymd("2023-08-23"))) |> mutate(obs = 1:84, explanatory_var = 1:84 + 10) # it is trivial to model the underlying daily series tslm_fit <- repro_data |> model(tslm = TSLM(obs ~ explanatory_var)) explanatory_scenarios <- scenarios( # trend continuing scenario continued_increase = new_data(repro_data, 38) |> mutate(explanatory_var = 84:(84 + 37) + 10), # trend reversing scenario decrease = new_data(repro_data, 38) |> mutate(explanatory_var = 84:(84 - 37) + 10) ) # forecast thru september fcast <- tslm_fit |> forecast(h = 38, new_data = explanatory_scenarios) # bind each scenario with past reality and then compute monthly means monthly_mean_fcast <- fcast |> as_tsibble(date, .scenario) |> select(.scenario, date, obs = .mean) |> bind_rows(map_dfr( names(explanatory_scenarios), ~ mutate(as_tibble(repro_data), .scenario = .x) )) |> index_by(yearmonth = yearmonth(date)) |> group_by_key() |> summarise( mean_obs = mean(obs, na.rm = TRUE) ) monthly_mean_fcast
As you can see, I can use the scenarios to forecast August and September, but it's in a roundabout way. I'm not directly modeling and forecasting the monthly mean. Is there a way to go more directly to the goal of forecasting the monthly mean and get prediction intervals in the process?