Learn R Programming

EpiNow2 (version 1.8.0)

get_predictions: Get predictions from a fitted model

Description

[Stable] Extracts predictions from a fitted model. For estimate_infections() returns predicted reported cases, for estimate_secondary() returns predicted secondary observations. For estimate_truncation() returns reconstructed observations adjusted for truncation.

Usage

get_predictions(object, ...)

# S3 method for estimate_infections get_predictions( object, format = c("summary", "sample", "quantile"), CrIs = c(0.2, 0.5, 0.9), quantiles = c(0.05, 0.25, 0.5, 0.75, 0.95), ... )

# S3 method for estimate_secondary get_predictions( object, format = c("summary", "sample", "quantile"), CrIs = c(0.2, 0.5, 0.9), quantiles = c(0.05, 0.25, 0.5, 0.75, 0.95), ... )

# S3 method for forecast_infections get_predictions( object, format = c("summary", "sample", "quantile"), CrIs = c(0.2, 0.5, 0.9), quantiles = c(0.05, 0.25, 0.5, 0.75, 0.95), ... )

# S3 method for forecast_secondary get_predictions( object, format = c("summary", "sample", "quantile"), CrIs = c(0.2, 0.5, 0.9), quantiles = c(0.05, 0.25, 0.5, 0.75, 0.95), ... )

# S3 method for estimate_truncation get_predictions( object, format = c("summary", "sample", "quantile"), CrIs = c(0.2, 0.5, 0.9), quantiles = c(0.05, 0.25, 0.5, 0.75, 0.95), ... )

Value

A data.table with columns depending on format:

  • format = "summary": date, mean, sd, median, and credible intervals

  • format = "sample": forecast_date, date, horizon, sample, predicted

  • format = "quantile": forecast_date, date, horizon, quantile_level, predicted

Arguments

object

A fitted model object (e.g., from estimate_infections(), estimate_secondary(), or estimate_truncation())

...

Additional arguments (currently unused)

format

Character string specifying the output format:

  • "summary" (default): summary statistics (mean, sd, median, CrIs)

  • "sample": raw posterior samples for scoringutils::as_forecast_sample()

  • "quantile": quantile predictions for scoringutils::as_forecast_quantile()

CrIs

Numeric vector of credible intervals to return. Defaults to c(0.2, 0.5, 0.9). Only used when format = "summary".

quantiles

Numeric vector of quantile levels to return. Defaults to c(0.05, 0.25, 0.5, 0.75, 0.95). Only used when format = "quantile".

Examples

Run this code
if (FALSE) {
# After fitting a model
# Get summary predictions (default)
predictions <- get_predictions(fit)

# Get sample-level predictions for scoringutils
samples <- get_predictions(fit, format = "sample")

# Get quantile predictions for scoringutils
quantiles <- get_predictions(fit, format = "quantile")
}

Run the code above in your browser using DataLab