enw_nowcast_summary: Summarise the posterior nowcast prediction

View source: R/postprocess.R

enw_nowcast_summaryR Documentation

Summarise the posterior nowcast prediction

Description

A generic wrapper around enw_posterior() with opinionated defaults to extract the posterior prediction for the nowcast ("pp_inf_obs" from the stan code). The functionality of this function can be used directly on the output of epinowcast() using the supplied summary.epinowcast() method.

Usage

enw_nowcast_summary(
  fit,
  obs,
  max_delay = NULL,
  timestep = "day",
  probs = c(0.05, 0.2, 0.35, 0.5, 0.65, 0.8, 0.95)
)

Arguments

fit

A cmdstanr fit object.

obs

An observation data.frame containing reference_date columns of the same length as the number of rows in the posterior and the most up to date observation for each date. This is used to align the posterior with the observations. The easiest source of this data is the output of latest output of enw_preprocess_data() or enw_latest_data().

max_delay

Maximum delay to which nowcasts should be summarised. Must be equal (default) or larger than the modelled maximum delay. If it is larger, then nowcasts for unmodelled dates are added by assuming that case counts beyond the modelled maximum delay are fully observed.

timestep

The timestep to used. This can be a string ("day", "week", "month") or a numeric whole number representing the number of days.

probs

A vector of numeric probabilities to produce quantile summaries for. By default these are the 5%, 20%, 80%, and 95% quantiles which are also the minimum set required for plotting functions to work.

Value

A data.frame summarising the model posterior nowcast prediction. This uses observed data where available and the posterior prediction where not.

See Also

summary.epinowcast()

Functions used for postprocessing of model fits build_ord_obs(), enw_add_latest_obs_to_nowcast(), enw_nowcast_samples(), enw_posterior(), enw_pp_summary(), enw_quantiles_to_long(), enw_summarise_samples(), subset_obs()

Examples

fit <- enw_example("nowcast")
enw_nowcast_summary(
  fit$fit[[1]],
  fit$latest[[1]],
  fit$max_delay
  )

seabbs/epinowcast documentation built on Aug. 28, 2024, 12:31 p.m.