Simulation and inference code for SARS-CoV-2 transmission within and between socio-economic groups in Kenya over the first three waves of COVID-19 in Kenya.
This code repository contains the underlying model code for the paper COVID-19 Transmission Dynamics Underlying Epidemic Waves in Kenya.
- Basic familiarity with the Julia programming language.
- Solutions of the infection process are generated using the performant, and well documented, package SciML/DifferentialEquations.jl. Familiarisation with this package is desirable.
- Hamiltonian MCMC (HMC) is implemented using the dynamicHMC.jl package. The log-likelihood function for parameters is directly defined in
KenyaCoVSD
, and log-likelihood gradients (necessary for HMC) are calculated using forward-mode automatic differentiation. The combination of ODE solutions and log-likelihood function gradients in code was inspired by DiffEqBayes.jl. A good conceptual introduction to HMC can be found here. - MCMC posterior draws for parameters are stored as a
Chains
struct from theMCMCChains
package. The MCMC draws for each county are available from theJLD2
objects stored in\modelfits
, e.g.
using JLD2,MCMCChains
import KenyaCoVSD
@load("modelfits/Nairobi_model.jld2") #Loads an object called model into Main scope which contains information about Nairobi county
model.MCMC_results.chain #Summary information of MCMC posterior draws
/opendatacsvs
folder contains .csv datafiles (see supplementary information for the main manuscript to read data file captions). This data is also present on the repository in the form of .jld2 datafiles, which are directly used in the tutorial notebooks (see below).
Please find the supplementary information containing further details on the data analysis, and mathematical/statistical reasoning and assumptions behind the model in /supplementary_info
as a Word file.
The source code for the module KenyaCoVSD
is located in /src
. KenyaCoVSD
is not part of the Julia package ecosystem general directory, therefore, to use this module:
- Clone this project using e.g. git clone.
- Activate the Julia REPL.
- cd to the directory containing the
Project.toml
andManifest.toml
files for the cloned repository. - Open the Package manager using
]
, activate and instantiate your copy ofKenyaCoVSD
by
(v1.6) pkg> activate .
(KenyaCoVSD) pkg> instantiate
This will download and precompile the dependencies for KenyaCoVSD
.
Code and saved fits for alternative model structures and sensitivity analysis are in sensitivity_analysis
. Considered alternative model structures are one-group and three-group models. Sensitivity analysis includes changing assumptions about rate of loss of immunity to reinfection with SARS-CoV-2, the relative susceptibility of individuals after a first episode, compared to naive individuals, and, the relative transmissibility of individuals in subsequent episodes of infection. The script sensitivity_analysis/model_selection.jl
runs and presents model selection. The scripts:
sensitivity_analysis/waning_immunity_sensitivity.jl
runs MCMC inference under a range of waning immunity assumptions.sensitivity_analysis/infectiousness_sensitivity.jl
runs MCMC inference under a range of subsequent episode infectiousness assumptions (these require an alternative formulation of the transmission model).sensitivity_analysis/sensitivity_analysis.jl
combines saved results from the two scripts above and prints MCMC posteriors for all parameters under each assumption as plots toplots/sensitivity_analysis_plots
.
We fitted a transmission to each of the 47 Kenyan counties. In the main paper analysis was presented in terms of aggregated pan-Kenyan totals. Please find county-specific plots of infections, daily deaths, daily PCR positive, overall population exposure and SES group specific R(t) in /plots/county_plots
.