Bayesian Modeling for Infectious Diseases Using
PyMC3 in Python: COVID-19 as a Case Study
Joseph Romaric Cheuteu Tazopap
Institute
African Institute for Mathematical Sciences Cameroon
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 1 / 31
Table of Contents
1 Context
2 Problematic and Objectives
3 Bayesian Modeling and PyMC3
4 Application: Mathematical Model of COVID-19
5 Results and Discussion
6 Conclusion and Perspectives
7 Acknowledgement
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 2 / 31
Context
Context
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 3 / 31
Context
Context
Initially detected in Wuhan (China) in December 2019, the outbreak
caused by COVID-19 spread rapidly around the world.
Coronavirus has continued its spread across the world, with more than
650 millions confirmed cases in 192 countries and more than 6
millions deathsa .
In order to understand the rapid spread of this disease, several
mathematical tools have been built for consistent, efficient and rapid
decision-making.
Chen et al, worked on a deterministic mathematical model to simulate
a novel Coronavirus infection’s phase-based transmissibility.
Tesfaye et al, have studied a stochastic model for the dynamics of
COVID-19 pandemic transmission.
Ngari et al, have worked on COVID-19 model parameters and state
estimates using Lagrange polynomial, Least Square
Approximation and Kenya Quarantine data.
a [Link]
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 4 / 31
Problematic and Objectives
Problematic and Objectives
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 5 / 31
Problematic and Objectives
Problematic and Objectives
Problematic
How Bayesian modeling using PyMC3 we help us to understand an Infectious
Disease such as COVID-19?
General Objective
Estimation of parameters of an SEIR model type of COVID-19 by considering
vaccination, asymptomatic and hospitalization.
Specific Objectives
1 Provide a comprehensive overview of Bayesian inference.
2 Implement a Mathematical model that incorporates the dynamics of
COVID-19 transmission.
3 Implement Bayesian models in PyMC3 to estimate crucial epidemiological
parameters of COVID-19.
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 6 / 31
Bayesian Modeling and PyMC3
Bayesian Modeling and PyMC3
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 7 / 31
Bayesian Modeling and PyMC3
Bayesian Statistical Inference
Bayesian Statistics is a data analysis method founded on Bayes’s theorem,
wherein the information in observed data is used to update the available
knowledge about parameters in a statistical model.
Bayesian Inference is a statistical inference technique where the probability
of an hypothesis is updated based on new information.
Bayes’s Formula
Let D1 , · · · , Dn be a set of events associated with a sample space Ω, where all
the events have non-zero probability of occurrence and they form a partition
of Ω. Let B be any event which occurs with D1 or · · · or Dn , then on the
probabilistic space (Ω, A, P) we have:
P(Di )P(B/Di )
P(Di /B) = PB (Di ) = . (1)
∑
n
P(Dk )P(B/Dk )
k=1
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 8 / 31
Bayesian Modeling and PyMC3
Bayesian approach to data analysis
Bayesian analysis approach is a statistical framework based on Bayesian
probability theory.
Assume that we have a sample of observations d1 , d2 , · · · , dn of a random
variable Y ∼ P(D/θ), where D = {d1 , · · · , dn } and θ is a parameter for the
distribution. We consider θ as a random variable as well and following Bayes’s
theorem of equation (1), we can write:
P(D/θ)P(θ) P(D/θ)P(θ
P(θ/D) = =∫ . (2)
P(D)
P(D/θ)P(θ)dθ
θ
P(θ/D) ∝ P(D/θ)P(θ). (3)
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 9 / 31
Bayesian Modeling and PyMC3
Bayesian approach to data analysis
P(D/θ): Likelihood which represents the probability of observing the data
given the values of the uncertain parameters .
P(θ): Prior distribution which represents the information about the
uncertain parameter θ.
P(θ/D): Posterior distribution which is proportional to the product of the
likelihood function and the prior distribution as we have in the equation
(3) and represents the distribution of parameters based on the observed data.
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 10 / 31
Bayesian Modeling and PyMC3
Markov Chain Monte Carlo
A Stochastic process is a collection of random variables indexed by time.
A Markov Chain is a particular kind of stochastic process with the
memoryless Markov property which indicates that, given its current state, the
system’s future behavior depends simply on its current state and not on the
events that led up to it.
Ergodic Theorem for Markov Chains
If {x1 , x2 , · · ·} is an irreducible, aperiodic and recurrent Markov Chain, then
there is a unique probability distribution π such that as N −→ ∞
P(xn ∈ A) −→ π(A) with A ∈ A.
∫
1 ∑
N
g(xn ) −→ g(x)π(x)dx.
N n=1
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 11 / 31
Bayesian Modeling and PyMC3
Metropolis-Hastings algorithm
It is an iterative procedure that uses an acceptance/rejection rule to achieve
convergence to the required distribution. The steps of the algorithm are as
follows:
1 Start with an initial θ0 estimate for the parameters values.
2 For each iteration i = 1, 2, · · ·
A new set of θ∗ is generated by sampling from a proposed distribution
J(θ∗ /θn−1 ) (symmetric).
Using the likelihood function, an r value is calculated:
{ }
P(θ∗ /D)P(θ∗ )
r = min ,1 .
P(θn−1 /D)P(θn−1 )
A random number with uniform distribution, α(0, 1) is generated. Then
the values of the parameters for this iteration are:
∗
θ if α < r
n
θ =
n−1
θ otherwise
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 12 / 31
Bayesian Modeling and PyMC3
PyMC3
PyMC3 is a probabilistic programming library for Python that provides tools
for constructing and fitting Bayesian models.
It can also be described as a robust library for Bayesian inference and
probabilistic programming. We have some important characteristics and ideas
of PyMC3 in Bayesian inference that make the process of defining and
Bayesian models easier:
1 Probabilistic programming
2 Model specification
3 Automatic differentiation
4 Markov Chain Monte Carlo
5 Variational inference
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 13 / 31
Application: Mathematical Model of COVID-19
Application: Mathematical Model of COVID-19
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 14 / 31
Application: Mathematical Model of COVID-19
Mathematical model of COVID-19 (SVEIAHR)
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 15 / 31
Application: Mathematical Model of COVID-19
Mathematical Equations of the model
dS
= θ − λS − (µ + ϕ)S + τ V1 ,
dt
dV1
= ϕS − (τ + σ + µ)V1 ,
dt
dV2
= σV1 − (η + µ)V2 ,
dt
dE
= λS − (ϵ + µ)E,
dt (4)
dA
= ϵ(1 − κ)E − (ψ + µ)A,
dt
dI
= ϵκE + ψ(1 − ρ)A − (δ + ω + µ)I,
dt
dH
= ω(1 − b)I − (δ + d + µ)H,
dt
dR
= ωbI + ψρA + dH + ηV2 − µR,
dt
α(βA A + βI I + βH H)
where λ = , with the initial conditions S(0) > 0, V1 (0) >
N(t)
0, V2 (0) > 0, E(0) > 0, A(0) > 0, I(0) > 0, H(0) > 0 and R(0) > 0.
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 16 / 31
Application: Mathematical Model of COVID-19
Mathematical Analysis: Well-Posedness
Positivity of solutions
∀t > 0 (S(t), V1 (t), V2 (t), E(t), A(t), I(t), H(t), R(t)) ∈ R8+ .
Boundedness of Trajectories
Then the domain
{( ) ( )}
θ
Ω= S, V1 , V2 , E, A, I, H, R ∈ R8+ , N ≤ max N(0), , (5)
µ
is a positively invariant set.
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 17 / 31
Application: Mathematical Model of COVID-19
Mathematical Analysis
Disease Free Equilibrium (DFE)
θ(τ + σ + µ)
S∗ = ,
µτ + (σ + µ)(µ + ϕ)
θϕ
V∗1 = ,
µτ + (σ + µ)(µ + ϕ)
θϕσ
V∗2 = ,
(η + µ) [µτ + (σ + µ)(µ + ϕ)]
θϕση
R∗ = .
µ(η + µ) [µτ + (σ + µ)(µ + ϕ)]
DFE = (S∗ , V∗1 , V∗2 , 0, 0, 0, 0, R∗ ) .
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 18 / 31
Application: Mathematical Model of COVID-19
Stability of the Disease Free Equilibrium
Here, we use the next generation matrix of Van Den Driessche and Watmough
methods.
R0 = ρ(FV−1 ). (6)
We obtain:
R0 = RA + RI + RH . (7)
where,
αS∗ βA ϵk5 αS∗ βI ϵ(ψk5 k7 + κk6 )
RA = , R I = , and
N∗ k4 k6 N∗ k4 k6 k8
αS∗ βH ϵωk9 (ψk5 k7 + κk6 ) θ
RH = ∗
, with N∗ = .
N k4 k6 k8 k10 µ
where k4 = ϵ + µ, k5 = 1 − κ, k6 = µ + ψ, k7 = 1 − ρ, k8 = µ + δ + ω, k9 =
1 − b and k10 = µ + δ + d.
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 19 / 31
Application: Mathematical Model of COVID-19
Sensitivity analysis of the model
Figure: Sensitivity analysis of the model.
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 20 / 31
Application: Mathematical Model of COVID-19
Parameters Estimation and Model Fitting
PyMC3, an advanced Markov Chain Monte Carlo and Variational fitting
algorithm-focused python program for Bayesian statistical modeling and
probabilistic machine learning, is used to estimate βA and βH .
θ = (βA , βH ).
D = The rolling 7-day average of the number of reported incidences.
Poisson distribution is chosen as the likelihood, meaning that if we have n
reported cases and D = {d1 , · · · , dn }, then
exp(−λi ) × λdi i
f(di ) = . (8)
di !
where λi is assumed to be the model’s answer.
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 21 / 31
Application: Mathematical Model of COVID-19
Parameters Estimation and Model Fitting
We assume
βA follows the Normal distribution.
βH follows the Lognormal distribution.
After estimating these parameters, we compute the NMSE to determine how
well the model matches the real data.
||[actual number of cases] − [predicted number of cases]||2
NMSE = 1 − .
||[actual number of cases] − [mean of actual number of cases]||2
where the 2-norm of a vector is denoted by ||·||. NMSE ∈ [−∞, 1], where 1
denotes a perfect fit and −∞ denotes a poor fit.
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 22 / 31
Results and Discussion
Results and Discussion
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 23 / 31
Results and Discussion
Parameter Estimation Values
Table: Statistical table of parameter estimated.
mean sd hdi_3% hdi_97% r_hat
βA 0.538 0.00 0.538 0.539 1.01
βH 0.343 0.002 0.339 0.347 1.01
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 24 / 31
Results and Discussion
Kernel Density Estimation and Trace
Figure: Kernel Density Estimation and Trace of βA .
Figure: Kernel Density Estimation and Trace of βH .
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 25 / 31
Results and Discussion
Posterior Distribution of βA and βH
(e)
(f)
Figure: (e) Posterior distribution of βA and (f) Posterior distribution of βH .
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 26 / 31
Results and Discussion
Simulation of real data against model data
Figure: Cumulative data and Model data simulated with estimated parameters.
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 27 / 31
Conclusion and Perspectives
Conclusion and Perspectives
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 28 / 31
Conclusion and Perspectives
Conclusion and Perspectives
Conclusion
We presented Bayesian statistical inference (Bayesian statistics, Bayesian
inference, Bayesian approach to data analysis).
We took from the literature a mathematical model of COVID-19 with
double-dose vaccination.
We estimated the parameters of the model by using PyMC3 and real data,
we obtain NMSE=0.88 which showed the model fits accurately the real
data.
Perspectives
We plan to extend this model to incorporate granular data.
We will apply Bayesian statistical inference (MCMC) method and other
estimation methods such as the Least Square approximation method to
compare the results.
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 29 / 31
Acknowledgement
Acknowledgement
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 30 / 31
Acknowledgement
Acknowledgment
I would like to thank The Mathematical Collaborative Forum.
My sincerely thank to the African Institute for Mathematical
Sciences.
I thank my tutor Dr. Aurelien Junior Noupelah from the African
Institute for Mathematical Sciences Cameroon.
A big thank to my supervisor Prof. Dr. Woldegbriel Assefa
Woldegerima from York University, Toronto, Canada, for his invaluable
support during my academic journey at the AIMS Cameroon up to today.
”I am actively seeking a PhD or Research Position”
[Link]@[Link]
Joseph Romaric Cheuteu Tazopap Diseases Bayesian Modeling November 14, 2024 31 / 31