forecast.lfq_fit: Forecast lineage frequencies

View source: R/forecast.R

forecast.lfq_fitR Documentation

Forecast lineage frequencies

Description

Projects lineage frequencies forward in time using the fitted model. Prediction uncertainty is quantified by parametric simulation from the estimated parameter distribution.

Usage

## S3 method for class 'lfq_fit'
forecast(
  object,
  horizon = 28L,
  ci_level = 0.95,
  n_sim = 1000L,
  sampling_noise = TRUE,
  effective_n = 100L,
  ...
)

Arguments

object

An lfq_fit object.

horizon

Number of days to forecast. Default 28 (4 weeks).

ci_level

Confidence level for prediction intervals. Default 0.95.

n_sim

Number of parameter draws for prediction intervals. Default 1000.

sampling_noise

Logical; add multinomial sampling noise to prediction intervals? Default TRUE. When TRUE, each draw includes both parameter uncertainty (from the MLE covariance) and observation-level multinomial sampling variability.

effective_n

Effective sample size for multinomial sampling noise. Default 100, corresponding to a typical weekly sequencing volume per reporting unit. Smaller values produce wider (more conservative) prediction intervals.

...

Unused.

Value

An lfq_forecast object (tibble subclass) with columns:

.date

Date.

.lineage

Lineage name.

.median

Median predicted frequency.

.lower

Lower prediction bound.

.upper

Upper prediction bound.

.type

"fitted" or "forecast".

Examples


sim <- simulate_dynamics(n_lineages = 3,
  advantages = c("A" = 1.2, "B" = 0.8), seed = 1)
fit <- fit_model(sim, engine = "mlr")
fc <- forecast(fit, horizon = 21)
fc



lineagefreq documentation built on April 3, 2026, 9:09 a.m.