/sir-model

A test repository that contains an SIR model

Primary LanguageRMIT LicenseMIT

SEIR Model

About This Project

This is a test project to get used to using Git and GitHub.

The purpose of this project is to create a frequency dependent SEIR model in R. An SEIR model is a model that describes the spread of a disease in a population, placing individuals in compartments based on their infection status. The compartments are susceptible (S), exposed (E), infected (I), and recovered (R). The model is described by the following equations:

$$\begin{align} \frac{dS}{dt} &= \mu (N - S) -\beta S \frac{I}{N} \\\ \frac{dE}{dt} &= \beta S \frac{I}{N} - \sigma E \\\ \frac{dI}{dt} &= \sigma E - \gamma I - \mu I \\\ \frac{dR}{dt} &= \gamma I - \mu R \end{align}$$ $$\begin{align} \mu &= \frac{1}{50*52} \\\ \beta &= 2 \\\ \sigma &= 1 \\\ \gamma &= \frac{1}{2} \\\\\ N &= 1.0 \\\ S_0 &= 0.999 \\\ E_0 &= 0 \\\ I_0 &= 0.001 \\\ R_0 &= 0.0 \end{align}$$

Here, $\mu$ is the mortality and birth rate, $\beta$ is the contact rate multiplied by the per-contact transmission probability, $\sigma$ is the latent rate, and $\gamma$ is the recovery rate. The units for this are weeks, so the life expectancy is 50 years, and the duration of infection (inverse of recovery rate) is 2 weeks.

Repository Structure

.
├── data/
├── figs/
├── funs/
├── out/
└── src/
  • data/ contains raw data.
  • figs/ contains figures generated by the code.
  • funs/ contains user-defined helper functions.
  • out/ contains intermediate data and output files.
  • src/ contains scripts for analysis.

Built With

Getting Started

I've used the {renv} package to manage the R environment for this project. For more details on how to use {renv}, see this article, but in brief, it creates a snapshot of the installed packages and their versions.

To get started, you will need to install {renv} as usual (i.e., install.packages("renv")), and then run renv::restore() to install the packages that are used in this project (the record in the renv.lock file).

Usage

To run the SIR model, you can open the src/sir_model.R file and run the code as usual.

License

This project is licensed under the MIT License - see the LICENSE file for details

Contact

You can contact me via my email: "arnold dot crk at gmail dot com".

Acknowledgements