The main entry point. Takes a tbl_now (from the tbl.now package) and a
model(), fits the latent-epidemic + reporting-delay model as of a given
date, and returns a nowcast_class object. Fitting only – the
posterior-predictive nowcast is produced lazily by predict(); the latent
incidence by mean()/median()/quantile(); the parameter estimates by
coef().
Usage
nowcast(
data,
model = diseasenowcasting::model(),
type = c("two_stage", "one_stage", "auto"),
now = NULL,
K = 25L,
n_draws = 2000L,
delay_window = 120L,
np_spread = 1,
floor_mu = 0.08,
floor_sig_frac = 0.08,
temporal_effects = "auto",
prior_only = FALSE,
seed = sample.int(.Machine$integer.max, 1),
...
)Arguments
- data
A
tbl_nowobject (tbl.now::tbl_now()).- model
- type
"two_stage"(default; delay-imputation pooling),"one_stage"(a single joint fit), or"auto"(per delay: dirichlet one-stage, all other delays two-stage – the better choice for each in our experiments).- now
As-of date; only events/reports up to
noware used. Default:tbl.now::get_now(data), falling back to the latest report date.- K
Number of delay imputations for the two-stage path.
- n_draws
Default number of posterior draws used by
predict()and the latent-incidence summaries.- delay_window
Recent window length for the parametric Stage-1 delay fit.
- np_spread
Dirichlet simplex imputation covariance inflation (default 1).
- floor_mu, floor_sig_frac
Imputation-spread floors (parametric families).
- temporal_effects
Controls automatic seasonal / day-of-week covariates.
"auto"(default) adds sensible effects based on the data's time unit (weekly -> 52-period seasonality; daily -> day-of-week + 52-period seasonality; monthly -> 12-period seasonality) only if thetbl_nowdoes not already carry computed temporal effects. Use"none"(or"None") to disable, or pre-attach your own effects to thetbl_nowwithtbl.now::add_temporal_effects()+tbl.now::compute_temporal_effects().- prior_only
If
TRUE, ignore the likelihood and draw the epidemic parameters from their priors only, returning the prior-predictive latent incidence. Useful for understanding what a prior implies before seeing data (e.g. how the SIRR0prior or the AR(1)phiprior reshapes the epidemic). The result is a normalnowcast_class, sopredict()/autoplot()/median()/quantile()all work;dataonly supplies the time grid. DefaultFALSE.- seed
Optional RNG seed (imputation draws).
- ...
Passed to
prepare_data()(e.g.gp_boundary_frac).
Overdispersion (phi)
The negative-binomial overdispersion prior is not an argument of
nowcast(). Set it on the likelihood instead, e.g.
model(nb_likelihood(phi = lognormal_prior(log(5), 0.5)), ...). The default
nb_likelihood() already uses lognormal_prior(log(20), 0.5).
Examples
if (requireNamespace("tbl.now", quietly = TRUE)) {
# data <- tbl.now::tbl_now(my_linelist, event_date = onset, report_date = reported)
# nc <- nowcast(data, model(nb_likelihood(), hsgp_epidemic(), lognormal_delay()))
# predict(nc); median(nc); coef(nc)
}
#> NULL
