knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
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)
contactmatrix that describes the relative amount of contact that members of one group (row) has with each other group (column). The contact matrix could be quantified directly, but we recommend using one of the package functions to create it.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() function computes the final number of infected people in each group at the end of the outbreak, by default using a deterministic ordinary differential equation (ODE) model and numerically solving the equations.finalsize(popsize, R0, contactmatrix, relsusc, reltransm, initR, initI, initV)
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")
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.
nsims argument, which defaults to 1 if unspecified.finalsize(popsize, R0, contactmatrix, relsusc, reltransm, initR, initI, initV, method = "stochastic", nsims = 10)
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)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.