get_plot_forecast_data: Combine 'load_truth()' and 'pivot_forecasts_wider()'

View source: R/get_plot_forecast_data.R

get_plot_forecast_dataR Documentation

Combine load_truth() and pivot_forecasts_wider()

Description

Combine load_truth() and pivot_forecasts_wider()

Usage

get_plot_forecast_data(
  forecast_data,
  truth_data = NULL,
  models_to_plot,
  forecast_dates_to_plot,
  horizons_to_plot,
  quantiles_to_plot,
  locations_to_plot = NULL,
  plot_truth = TRUE,
  truth_source,
  target_variable_to_plot,
  truth_as_of = NULL,
  hub = c("US", "ECDC", "FluSight")
)

Arguments

forecast_data

required data.frame with forecasts in the format returned by load_forecasts(). It has columns model, forecast_date, location, target, type, quantile, value, horizon and target_end_date.

truth_data

optional data.frame from one truth source in the format returned by load_truth(). It needs to have columns model, target_variable, target_end_date, location and value. Model column can be "Observed Data (a truth source)".

models_to_plot

characters of model abbreviations

forecast_dates_to_plot

date string vectors for forecast dates to plot. Default to all forecast dates available in forecast_data.

horizons_to_plot

forecasts are plotted for the horizon time steps after the forecast date.

quantiles_to_plot

vector of quantiles to include in the plot

locations_to_plot

a vector of strings of fips code or CBSA codes or location names, such as "Hampshire County, MA", "Alabama", "United Kingdom". A US county location names must include state abbreviation. Default to NULL which would include all locations available in forecast_data.

plot_truth

logical to indicate whether truth data should be plotted. Default to TRUE.

truth_source

character specifying where the truth data will be loaded from if truth_data is not provided. Currently support "JHU", ⁠NYTimes"⁠ and "HealthData". Optional if truth_data is provided.

target_variable_to_plot

string specifying target type. It should be one of "cum death", "inc case", "inc death", "inc hosp" and "inc flu hosp".

truth_as_of

the plot includes the truth data that would have been in real time as of the truth_as_of date.

hub

character, which hub to use. Default is "US". Other options are "ECDC" and "FluSight".

Value

data.frame with columns model, forecast_date, location, target_variable, type, quantile, value, horizon and target_end_date.


reichlab/covidHubUtils documentation built on Feb. 6, 2024, 1:42 p.m.