R/plot_forecasts.R
plot_forecast.Rd
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
)
required data.frame with forecasts in the format returned
by load_forecasts()
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)"
.
character vector, where the first element indicates the hub
from which to load forecasts.
Possible options are "US"
, "ECDC"
and "FluSight"
.
vector of strings specifying models to plot.
Default to all models in forecast_data
.
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.
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
.
interpretable facet option for ggplot. Function will error if multiple locations are passed in without location in the facet formula.
argument for scales in ggplot2::facet_wrap. Default to "fixed"
.
number of rows for facetting; optional.
number of columns for facetting; optional.
date string vectors for forecast dates to plot. Default to forecast_dates present in the data.
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.
forecasts are plotted for the horizon time steps after the
forecast date. Default to all available horizons in forecast_data
.
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.
logical for using median quantiles as point forecasts in plot.
Default to FALSE
.
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
.
logical for showing the plot. Default to TRUE
.
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
.
numeric value used to set transparency of intervals. 0 means fully transparent, 1 means opaque.
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)
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.
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.
logical, if TRUE
, caption will be included showing data sources
invisible ggplot object