Skip to contents

Creates a validated configuration object for running state-level NHSN nowcasts.

Usage

nowcast_config(
  max_delay = 7L,
  scale_factor = 3,
  prop_delay = 0.5,
  uncertainty_model = c("negative_binomial", "normal", "skellam"),
  draws = 1000L,
  robust_sample = FALSE,
  nonneg_pred = FALSE,
  location = NULL,
  output_dir = NULL
)

Arguments

max_delay

Integer. Maximum delay (in weeks) to consider for the reporting triangle. Default is 7.

scale_factor

Numeric. Multiplicative factor on max_delay for training volume in baselinenowcast. Default is 3.

prop_delay

Numeric between 0 and 1. Proportion of training data used for delay estimation. Default is 0.5.

uncertainty_model

Character. One of "negative_binomial" (default), "normal", or "skellam". Specifies the uncertainty model for probabilistic nowcasts.

draws

Integer. Number of posterior draws for probabilistic nowcasts. Default is 1000.

robust_sample

Logical. If TRUE, make the uncertainty sampler robust so it can always draw. For the "skellam" model this increases the variance to the minimum value that yields valid (positive) Poisson rates for the given nowcast mean, instead of erroring when variance <= |pred| (see sample_skellam()). No-op for "normal" and "negative_binomial", which cannot fail this way. Default is FALSE.

nonneg_pred

Logical. If TRUE, clamp negative predicted counts in the final nowcast to 0. This guards against draws where the summed revisions push the combined count below zero, at the cost of distorting the probabilistic model near zero. Default is FALSE.

location

Character. A single location code (e.g., "ca"). Default is NULL, meaning no specific location is set.

output_dir

Character. Directory path for partitioned parquet output. If NULL, results are returned but not written to disk. Default is NULL.

Value

A list of class nowcast_config containing validated parameters.

Examples

# Default configuration
config <- nowcast_config()

# Custom configuration for a single state
config <- nowcast_config(
  max_delay = 5,
  uncertainty_model = "skellam",
  location = "ca",
  output_dir = "output/nowcasts"
)

# Configuration with fewer draws
config <- nowcast_config(
  draws = 500
)