[Deprecated] Please use plot_forecasts() instead.

plot_forecast(
  forecast_data,
  truth_data = NULL,
  hub = c("US", "ECDC", "FluSight"),
  models = NULL,
  target_variable,
  locations = NULL,
  facet = NULL,
  facet_scales = "fixed",
  facet_nrow = NULL,
  facet_ncol = NULL,
  forecast_dates = NULL,
  intervals,
  horizon,
  truth_source,
  use_median_as_point = FALSE,
  plot_truth = TRUE,
  plot = TRUE,
  fill_by_model = FALSE,
  fill_transparency = 1,
  truth_as_of = NULL,
  title = "default",
  subtitle = "default",
  show_caption = TRUE
)

Arguments

forecast_data

required data.frame with forecasts in the format returned by load_forecasts()

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)".

hub

character vector, where the first element indicates the hub from which to load forecasts. Possible options are "US", "ECDC" and "FluSight".

models

vector of strings specifying models to plot. Default to all models in forecast_data.

target_variable

string specifying target type. It should be one of "cum death", "inc case", "inc death", "inc hosp" and "inc flu hosp". "cum death" and "inc hosp" are only available in forecasts from US hub now. If there is only one target_variable in forecast_data, this parameter is optional.

locations

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 in forecast_data.

facet

interpretable facet option for ggplot. Function will error if multiple locations are passed in without location in the facet formula.

facet_scales

argument for scales in ggplot2::facet_wrap. Default to "fixed".

facet_nrow

number of rows for facetting; optional.

facet_ncol

number of columns for facetting; optional.

forecast_dates

date string vectors for forecast dates to plot. Default to forecast_dates present in the data.

intervals

values indicating which central prediction interval levels to plot. NULL means only plotting point forecasts. If not provided, it will default to c(.5, .8, .95). When plotting 6 models or more, the plot will be reduced to show .95 interval only.

horizon

forecasts are plotted for the horizon time steps after the forecast date. Default to all available horizons in forecast_data.

truth_source

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

use_median_as_point

logical for using median quantiles as point forecasts in plot. Default to FALSE.

plot_truth

logical for showing truth data in plot. Default to TRUE. Data used in the plot is either truth_data or data loaded from truth_source.

plot

logical for showing the plot. Default to TRUE.

fill_by_model

logical for specifying colors in plot. If TRUE, separate colors will be used for each model. If FALSE, only blues will be used for all models. Default to FALSE.

fill_transparency

numeric value used to set transparency of intervals. 0 means fully transparent, 1 means opaque.

truth_as_of

the plot includes the truth data that would have been in real time as of the truth_as_of date (not using this parameter when truth data is from github repo)

title

optional text for the title of the plot. If left as "default", the title will be automatically generated. If "none", no title will be plotted.

subtitle

optional text for the subtitle of the plot. If left as "default", the subtitle will be automatically generated. If "none", no subtitle will be plotted.

show_caption

logical, if TRUE, caption will be included showing data sources

Value

invisible ggplot object