draw_R: Draw R from marginal posterior distribution

View source: R/gibbs_draws.R

draw_RR Documentation

Draw R from marginal posterior distribution

Description

Draw R from marginal posterior distribution

Usage

draw_R(
  epsilon,
  incid,
  lambda,
  priors,
  shape_R_flat = NULL,
  t_min = NULL,
  t_max = nrow(incid),
  seed = NULL
)

Arguments

epsilon

a value or vector of values for the relative transmissibility of the "new" pathogen/strain/variant(s) compared to the reference pathogen/strain/variant

incid

a multidimensional array containing values of the (local) incidence for each time step (1st dimension), location (2nd dimension) and pathogen/strain/variant (3rd dimension)

lambda

a multidimensional array containing values of the overall infectivity for each time step (1st dimension), location (2nd dimension) and pathogen/strain/variant (3rd dimension). The overall infectivity for a given location and pathogen/strain/variant represents the sum of the incidence for that location and that pathogen/strain/variant at all previous time steps, weighted by the current infectivity of those past incident cases. It can be calculated from the incidence 'incid' and the distribution of the serial interval using function 'compute_lambda')

priors

a list of prior parameters (shape and scale of a gamma distribution) for epsilon and R; can be obtained from the function 'default_priors'. The prior for R is assumed to be the same for all time steps and all locations

shape_R_flat

a vector of the shape of the posterior distribution of R for each time step t and each location l (stored in element (l-1)*(t_max - t_min + 1) + t of the vector), as obtained from function 'get_shape_R_flat'

t_min

an integer >1 giving the minimum time step to consider in the estimation. Default value is 2 (as the estimation is conditional on observations at time step 1 and can therefore only start at time step 2).

t_max

an integer >'t_min' and <='nrow(incid)' giving the maximum time step to consider in the estimation. Default value is 'nrow(incid)'.

seed

a numeric value used to fix the random seed

Value

a matrix of the instantaneous reproduction number R for the reference pathogen/strain/variant for each time step (row) and each location (column) drawn from the marginal posterior distribution

Examples


n_v <- 2
n_loc <- 3 # 3 locations
T <- 100 # 100 time steps
priors <- default_priors()
# constant incidence 10 per day everywhere
incid <- array(10, dim = c(T, n_loc, n_v))
incid <- process_I_multivariant(incid)
# arbitrary serial interval, same for both variants
w_v <- c(0, 0.2, 0.5, 0.3)
si_distr <- cbind(w_v, w_v)
lambda <- compute_lambda(incid, si_distr)
# Epsilon = 1 i.e. no transmission advantage
epsilon <- 1
draw_R(epsilon, incid$local, lambda, priors, seed = 1, t_min = 2L)


annecori/EpiEstim documentation built on Sept. 7, 2024, 7:34 p.m.