Plots histograms showing empirical coverage of credible intervals specified using 'levels'. Can bucket by time period, by group, by whether the observation is new (not used in fitting).

plot_coverage(
  object,
  type,
  newdata = NULL,
  groups = NULL,
  levels = c(50, 95),
  period = NULL,
  by_group = FALSE,
  by_unseen = FALSE
)

Arguments

object

A fitted model object returned by epim. See epimodel-objects.

type

A string specifying the name of the observations to plot. This should match one of the names of the response variables in the obs argument used int the call to epim.

newdata

If provided, the original data used in object is overridden. Useful for forecasting

groups

Either NULL or a character vector specifying the groups to plot for. Default is NULL, which plots all modeled groups.

levels

A numeric vector defining the levels of the plotted credible intervals.

period

Buckets computed empirical probabilities into time periods if specified.

by_group

Plot coverage for each group individually

by_unseen

Plot coverage separately for seen and unseen observations. Observations are 'seen' if they were used for fitting.

Value

A ggplot object.