plot_forecast: Plot observed history, fitted values and forecast with...

View source: R/plot.R

plot_forecastR Documentation

Plot observed history, fitted values and forecast with uncertainty

Description

Shows the observed series together with the in-sample fitted mean (median and credible band) and the forecast (median and credible band) over the forecast horizon. The forecast is the one stored in the fit, or a new one computed with forecast.dynamic_fit() when horizon (or another forecast input) is supplied. For the multinomial family, one panel per category.

Usage

plot_forecast(
  object,
  level = 0.95,
  category = NULL,
  horizon = NULL,
  forecast_offset = NULL,
  forecast_trials = NULL,
  seed = NULL,
  ...
)

Arguments

object

A "dynamic_fit" object.

level

Credible level. Default 0.95.

category

Multinomial family only: which categories to draw (names or indices among the non-baseline categories for plot_latent(); among all K categories for plot_fitted() and plot_forecast()). NULL (default) draws one panel per category.

horizon, forecast_offset, forecast_trials, seed

Passed to forecast.dynamic_fit(). With the defaults, the forecast stored in the fit is plotted.

...

Passed to graphics::plot(); may override the default main, xlab, ylab, ylim and other plot arguments.

Value

Invisibly, the "dynamic_forecast" object.

Examples

sim <- simulate_dynamic_poisson(60, 0.2, 2, seed = 1)
fit <- fit_dynamic_model(sim$y, nsave = 300, nburn = 200, seed = 1)
plot_forecast(fit, horizon = 12)

DynCount documentation built on Sept. 28, 2026, 5:10 p.m.