Skip to contents

r_eff calculates the effective reproductive number \(R_eff\) in a population with heterogeneous mixing, and with heterogeneous susceptibility to infection such as due to immunisation.


r_eff(r0, contact_matrix, demography_vector, susceptibility, p_susceptibility)



The basic reproductive number \(R_0\) of the infection.


Social contact matrix. Entry \(m_{ij}\) gives average number of contacts in group \(i\) reported by participants in group \(j\)


Demography vector. Entry \(v_{i}\) gives proportion of total population in group \(i\) (model will normalise if needed).


A matrix giving the susceptibility of individuals in demographic group \(i\) and risk group \(k\).


A matrix giving the probability that an individual in demography group \(i\) is in risk (or susceptibility) group \(k\). Each row represents the overall distribution of individuals in demographic group \(i\) across risk groups, and each row must sum to 1.0.


A single number of the effective reproductive number of the infection in the population.


# load example POLYMOD data included in the package
r0 <- 2.0
contact_matrix <- polymod_uk$contact_matrix
demography_vector <- polymod_uk$demography_vector

# define the number of age and susceptibility groups
n_demo_grps <- length(demography_vector)
n_risk_grps <- 3

# In this example, all risk groups from all age groups are fully
# susceptible
susceptibility <- matrix(
  data = 1, nrow = n_demo_grps, ncol = n_risk_grps

p_susceptibility <- matrix(
  data = 1, nrow = n_demo_grps, ncol = n_risk_grps
# p_susceptibility rows must sum to 1.0
p_susceptibility <- p_susceptibility / rowSums(p_susceptibility)

# calculate R_effective
  r0 = r0,
  contact_matrix = contact_matrix,
  demography_vector = demography_vector,
  susceptibility = susceptibility,
  p_susceptibility = p_susceptibility
#> [1] 2