epiinf defines a model for latent infections. For the basic version of the model, this defines the generation distribution of the disease, the number of days for which to seed infections, and the prior distribution on the parameter \(\tau\), as described in the model description vignette. Recall that \(\tau\) is the prior mean on daily seeded infections. These three parameters are controlled by the arguments gen, seed_days and prior_seeds respectively.

epiinf(
  gen,
  seed_days = 6L,
  prior_seeds = hexp(prior_aux = rstanarm::exponential(0.03)),
  latent = FALSE,
  family = "normal",
  prior_aux = rstanarm::normal(10, 5),
  fixed_vtm = 1,
  pop_adjust = FALSE,
  pops = NULL,
  rm = NULL,
  prior_susc = NULL,
  prior_rm_noise = NULL,
  gen_group = NULL,
  importations = FALSE,
  prior_importations = rstanarm::normal(0, 0.2)
)

Arguments

gen

A numeric vector representing the probability mass function for the generation time of the disease (must be a probability vector; discretize_cdf makes one from a continuous distribution). Its \(k\)th element is the probability that the generation time is \(k\) days, and it is used for every group. To give groups different generation distributions, use instead a named list of such vectors, or a matrix whose (named) columns are such vectors. These are matched to groups by name, or by gen_group. Distributions of different lengths are padded with zeros.

seed_days

An integer giving the number of days for which to seed infections. Defaults to 6L.

prior_seeds

The prior distribution on seeded infections. This may be a call to normal, student_t, exponential, lognormal, or to hexp. The latter distribution allows hierarchical modeling of seeded infections.

latent

If TRUE, treat infections as latent parameters using the extensions described in Section 5.2 here.

family

Specifies the family for the prior distribution on daily infections. Only used if latent = TRUE, and currently restricted to normal.

prior_aux

Prior distribution for the auxiliary variable in the distribution for latent infections. Only used if latent = TRUE. If fixed_vtm = TRUE, then this refers to the variance-to-mean ratio. If fixed_vtm = FALSE, it is instead the coefficient of variation. Can be a call to exponential, normal, student_t or cauchy. These result in half-normal, half-t and half-cauchy priors.

fixed_vtm

If TRUE, then the prior variance-to-mean ratio for latent infections is fixed, i.e. the auxiliary variable refers to the coefficient of dispersion. If FALSE, then the prior ratio of standard deviation to mean is fixed instead, and the auxiliary variable refers to the coefficient of variation.

pop_adjust

If TRUE, applies a population adjustment to the infection process. Defaults to FALSE.

pops

A character vector giving the name of the column in the dataframe corresponding to the population of each group.

rm

A characted vector giving a column name in data (see epim). Each entry should be the proportion of the susceptible population in that group that are removed at that point by some means other than infection; i.e. vaccination. Only used if pop_adjust=TRUE.

prior_susc

Prior distribution on the initial susceptible population at time 0, expressed as a proportion of the total population size. This quantity lies between 0 and 1, and is useful when the first modeled date is after the true beginning of an epidemic. Only used when pop_adjust = TRUE. If unspecified, then the entire population is assumed to be susceptible at time 0. If specified, should be a call to normal.

prior_rm_noise

Removal from the susceptible population (to account for vaccinations) can be applied using the rm argument. However, in practice, it is difficult to specify the proportion of the susceptible class removed at any point in time. prior_rm_noise helps to model noise around this. If specified, should be a call to normal.

gen_group

Only used if gen holds several generation distributions. A vector, named by group, giving for each modeled group the name (or position) of the element of gen that it uses. This allows groups to share a distribution, for example one per region. If NULL (the default), the names of gen must include every modeled group.

importations

If TRUE, each group has a constant number of imported infections every day after the seeding period, \(\iota\), an unknown parameter, so that the renewal equation becomes \(i_t = R_t \sum_{s < t} i_s g_{t-s} + \iota\). Imported infections keep an epidemic going when \(R_t < 1\), so they matter most when counts are low; they can also make \(R_t\) harder to identify there. Defaults to FALSE.

prior_importations

Prior distribution on the daily importations \(\iota\) of each group, which are on the scale of infections. Only used if importations = TRUE. Can be a call to normal, student_t, cauchy or exponential; the first three are truncated at zero. The default, a half-normal with scale 0.2, suits small numbers of importations; choose a scale to suit the size of the epidemic.

Value

An object of class epiinf.

Details

epiinf has additional arguments which allow the user to extend the basic model. Using latent=TRUE replaces the renewal process with a model that treats latent infections as unknown parameters that are sampled along with other parameters. The family argument then gives the distribution family for latent infections, while prior_aux defines the prior on the coefficient of dispersion \(d\) of this distribution.

Recall that one can adjust the infection process to explicitly model changes in infection rates as the remaining susceptible population is depleted. In particular, the adjustment ensures that cumulative infections never breaches the initial susceptible population. The adjustment was described in Section 5.3 of the model description article. It can be employed by setting pop_adjust = TRUE and using the susceptibles argument to point towards a variable in the dataframe which gives the susceptible population at each point in time.

Examples

data(EuropeCovid)
inf <- epiinf(
 gen = EuropeCovid$si,
 seed_days = 6L,
 prior_seeds = hexp(rstanarm::exponential(0.02))
)

# a faster generation distribution in some groups
fast <- EuropeCovid$si[1:20] / sum(EuropeCovid$si[1:20])
inf <- epiinf(
 gen = list(slow = EuropeCovid$si, fast = fast),
 gen_group = c(Italy = "fast", Spain = "fast", Germany = "slow")
)