Getting Started Example

This vignette walks through a first example of setting up a multi-group epidemic model and calculating useful quantities for analysis using functions in this R package. After installing the package (see instructions in README), load it:

library(multigroup.vaccine)

In our example model, we consider a population of size 10,000 individuals and with the following parameters:

popsize <- c(80000, 20000)

In this example we use a model for “proportionate contacts with preferential mixing”, making use of our contactMatrixPropPref() function, which requires the following components. This contact model can allows for different overall contact rates of members of each group. Here we assume the relative contact rates are 1 and 1.7 for groups A and B. This means that an individual in Group B makes 1.7 contacts for every 1 made by an individual in group A.

relcontact <- c(1, 1.7)

This contact model also can also assume preferential mixing within one’s own group. We assume that the fraction of contacts that are exclusively within-group is 0.2 for group A, and 0.5 for group B. For group A, this means that 20% of their contacts are exclusively with other members of group A, and the remaining 80% of contacts are split between both groups A and B at rates proportional to the population sizes and overall contact rates of each group. The latter element ensures that the overall number of A-to-B and B-to-A contacts are equal, for contact symmetry.

incontact <- c(0.2, 0.5)

With the above elements, we calculate the contact matrix as follows

contactmatrix <- contactMatrixPropPref(popsize, relcontact, incontact)
relsusc <- c(1, 1.05)
reltransm <- c(1, 1.01)
R0 <- 1.75
initR <- c(0, 0)
initI <- c(0, 1)
initV <- c(0.3, 0.2) * popsize
finalsize(popsize, R0, contactmatrix, relsusc, reltransm, initR, initI, initV)
#> [1] 14139.571  8749.608

Over one third of the infected individuals are from population B, despite the fact that they comprise only one fifth of the population.

finalsize(popsize, R0, contactmatrix, relsusc, reltransm, initR, initI, initV, method = "analytic")
#> [1] 14139.571  8749.609

While the analytic method might seem preferable, it is not necessarily faster or more stable than the ODE numerical solution method, as the analytic method still involves numerical estimation methods required to solve the transcendental equations. We recommend using the default ODE method, especially for models with a large number of groups.

finalsize(popsize, R0, contactmatrix, relsusc, reltransm, initR, initI, initV, method = "stochastic",
          nsims = 10)
#>        [,1] [,2]
#>  [1,]     2    3
#>  [2,]     4    9
#>  [3,]     0    3
#>  [4,]     0    1
#>  [5,]     0    1
#>  [6,] 14927 9068
#>  [7,]     0    1
#>  [8,]     3    3
#>  [9,]     5    1
#> [10,] 14577 8763

Each row of the output has the results of one of the stochastic simulations for the final outbreak size of each group (including the initial one case in group B). We see that some simulations end after no or a small number of transmissions due to random luck, while others grow to a size close to the final size result from the deterministic results above.

finalsize(popsize, R0, contactmatrix, relsusc, reltransm, initR, initI, initV, method = "hybrid",
          nsims = 10)
#>        [,1] [,2]
#>  [1,]     0    1
#>  [2,] 14140 8750
#>  [3,]     0    3
#>  [4,] 14140 8750
#>  [5,]     0    1
#>  [6,]     1    2
#>  [7,]     0    1
#>  [8,]     0    3
#>  [9,]     0    1
#> [10,]     0    1