Converts a ForecastBaselines_Forecast object to the hubverse format used by hubVis for visualization. Returns a list with model_output and target_data data frames.

as_hubverse(
  data,
  start_date = NULL,
  horizon_unit = c("day", "week", "month"),
  observed_data = NULL
)

Arguments

data

A ForecastBaselines_Forecast object with quantiles, or a scoringutils forecast_quantile object

start_date

Optional start date for the time series. If NULL (default), uses horizon numbers as target_date values. Can be a Date object or character string in "YYYY-MM-DD" format.

horizon_unit

Character string specifying the time unit for horizons. One of "day" (default), "week", or "month". Used when start_date is provided.

observed_data

Optional numeric vector of all observed values (training + test). If provided, will be used to populate target_data with complete historical context.

Value

A list with two elements:

model_output

Data frame (model_out_tbl) with columns: target_date, value, model_id, output_type, output_type_id

target_data

Data frame with columns: date, observation

Details

The hubVis package is not on CRAN and must be installed from GitHub: remotes::install_github("hubverse-org/hubVis")

Examples

if (FALSE) { # \dontrun{
# With observed data for complete visualization context
hubverse_data <- as_hubverse(forecast,
  start_date = "2024-01-01",
  horizon_unit = "week",
  observed_data = full_data
)

# Install hubVis from GitHub for visualization
# remotes::install_github("hubverse-org/hubVis")

# Visualize with hubVis (if installed)
# Note: as_hubverse() automatically converts model_output to model_out_tbl
if (requireNamespace("hubVis", quietly = TRUE)) {
  hubVis::plot_step_ahead_model_output(
    hubverse_data$model_output,
    hubverse_data$target_data
  )
}
} # }