Skip to content

Commit

Permalink
Change wording
Browse files Browse the repository at this point in the history
  • Loading branch information
danielvartan committed Oct 25, 2024
1 parent 14d4661 commit e9a5bba
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

🦠🤒💉🤧💊🚑🧑‍⚕️🧪🏥😷🌍🌡️🔬🚨⚠️🧴🛑

This repository contains a demonstration of the [SIR model](https://en.wikipedia.org/wiki/Compartmental_models_in_epidemiology), originally introduced by Kermack and McKendrick in [1927](https://royalsocietypublishing.org/doi/10.1098/rspa.1927.0118). The SIR model is a foundational framework in epidemiology, designed to analyze the spread of infectious diseases by categorizing the population into three compartments: Susceptible (S), Infected (I), and Recovered (R).
This repository contains an illustration of the [SIR model](https://en.wikipedia.org/wiki/Compartmental_models_in_epidemiology), originally introduced by Kermack and McKendrick in [1927](https://royalsocietypublishing.org/doi/10.1098/rspa.1927.0118). The SIR model is a foundational framework in epidemiology, designed to analyze the spread of infectious diseases by categorizing the population into three compartments: Susceptible (S), Infected (I), and Recovered (R).

The report is available [here](https://danielvartan.github.io/sir/).
28 changes: 16 additions & 12 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="generator" content="quarto-1.5.40">
<meta name="generator" content="quarto-1.5.57">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<meta name="author" content="Daniel Vartanian">
<meta name="dcterms.date" content="2024-09-19">
<meta name="dcterms.date" content="2024-10-25">
<title>SIR Model</title>
<style>
code{white-space: pre-wrap;}
Expand Down Expand Up @@ -169,7 +169,7 @@ <h1 class="title">SIR Model</h1>
<div>
<div class="quarto-title-meta-heading">Published</div>
<div class="quarto-title-meta-contents">
<p class="date">2024-09-19</p>
<p class="date">2024-10-25</p>
</div>
</div>

Expand All @@ -180,7 +180,7 @@ <h1 class="title">SIR Model</h1>

</header><!-- badges: start --><p><a href="https://www.repostatus.org/#inactive"><img src="https://www.repostatus.org/badges/latest/inactive.svg" class="img-fluid" alt="Project Status: Inactive – The project has reached a stable, usable state but is no longer being actively developed; support/maintenance will be provided as time allows."></a> <a href="https://choosealicense.com/licenses/mit/"><img src="https://img.shields.io/badge/license-MIT-green.png" class="img-fluid" alt="License: MIT"></a> <!-- badges: end --></p>
<section id="overview" class="level2"><h2 class="anchored" data-anchor-id="overview">Overview</h2>
<p>This document focuses on demonstrating the <a href="https://en.wikipedia.org/wiki/Compartmental_models_in_epidemiology">SIR model</a>, originally introduced by Kermack and McKendrick in <span class="citation" data-cites="kermack1927">(<a href="#ref-kermack1927" role="doc-biblioref">1927</a>)</span>. The SIR model is a foundational framework in epidemiology, designed to analyze the spread of infectious diseases by categorizing the population into three compartments: Susceptible (S), Infected (I), and Recovered (R).</p>
<p>This document focuses on illustrating the <a href="https://en.wikipedia.org/wiki/Compartmental_models_in_epidemiology">SIR model</a>, originally introduced by Kermack and McKendrick in <span class="citation" data-cites="kermack1927">(<a href="#ref-kermack1927" role="doc-biblioref">1927</a>)</span>. The SIR model is a foundational framework in epidemiology, designed to analyze the spread of infectious diseases by categorizing the population into three compartments: Susceptible (S), Infected (I), and Recovered (R).</p>
<p>The dynamics of the model are represented by the following set of first-order, nonlinear differential equations:</p>
<p><span class="math display">\[
\begin{aligned}
Expand All @@ -189,8 +189,13 @@ <h1 class="title">SIR Model</h1>
\frac{dR}{dt} &amp;= \gamma I
\end{aligned}
\]</span></p>
<p>Here, <span class="math inline">\(\beta\)</span> represents the transmission rate, and <span class="math inline">\(\gamma\)</span> is the recovery rate.</p>
</section><section id="setting-up-the-environment" class="level2"><h2 class="anchored" data-anchor-id="setting-up-the-environment">Setting up the environment</h2>
<p>where,</p>
<ul>
<li>
<span class="math inline">\(\beta\)</span> represents the transmission rate;</li>
<li>
<span class="math inline">\(\gamma\)</span> represents the recovery rate.</li>
</ul></section><section id="setting-up-the-environment" class="level2"><h2 class="anchored" data-anchor-id="setting-up-the-environment">Setting up the environment</h2>
<div class="cell">
<details open="" class="code-fold"><summary>Code</summary><div class="sourceCode" id="cb1"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://mllg.github.io/checkmate/">checkmate</a></span>, quietly <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="http://desolve.r-forge.r-project.org/">deSolve</a></span>, quietly <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
Expand Down Expand Up @@ -376,26 +381,25 @@ <h1 class="title">SIR Model</h1>
<span> <span class="fu">checkmate</span><span class="fu">::</span><span class="fu"><a href="https://mllg.github.io/checkmate/reference/checkNumber.html">assert_number</a></span><span class="op">(</span><span class="va">theta</span>, lower <span class="op">=</span> <span class="fl">0</span><span class="op">)</span></span>
<span> <span class="fu">checkmate</span><span class="fu">::</span><span class="fu"><a href="https://mllg.github.io/checkmate/reference/checkNumber.html">assert_number</a></span><span class="op">(</span><span class="va">phi</span>, lower <span class="op">=</span> <span class="fl">0</span><span class="op">)</span></span>
<span></span>
<span> <span class="va">colors</span> <span class="op">&lt;-</span> <span class="fu">gg_color_hue</span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/length.html">length</a></span><span class="op">(</span><span class="va">beta</span><span class="op">)</span><span class="op">)</span></span>
<span> <span class="va">plot</span> <span class="op">&lt;-</span><span class="fu">ggplot2</span><span class="fu">::</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html">ggplot</a></span><span class="op">(</span><span class="op">)</span></span>
<span> </span>
<span> <span class="kw">for</span> <span class="op">(</span><span class="va">j</span> <span class="kw">in</span> <span class="fu"><a href="https://rdrr.io/r/base/seq.html">seq_along</a></span><span class="op">(</span><span class="va">beta</span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span>
<span> <span class="kw">for</span> <span class="op">(</span><span class="va">j</span> <span class="kw">in</span> <span class="va">beta</span><span class="op">)</span> <span class="op">{</span></span>
<span> <span class="va">data_j</span> <span class="op">&lt;-</span> </span>
<span> <span class="fu">sir</span><span class="op">(</span><span class="va">s</span>, <span class="va">i</span>, <span class="va">r</span>, <span class="va">beta</span><span class="op">[</span><span class="va">j</span><span class="op">]</span>, <span class="va">lambda</span>, <span class="va">from</span>, <span class="va">to</span>, <span class="va">by</span><span class="op">)</span> <span class="op">|&gt;</span></span>
<span> <span class="fu">sir</span><span class="op">(</span><span class="va">s</span>, <span class="va">i</span>, <span class="va">r</span>, <span class="va">j</span>, <span class="va">lambda</span>, <span class="va">from</span>, <span class="va">to</span>, <span class="va">by</span><span class="op">)</span> <span class="op">|&gt;</span></span>
<span> <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://magrittr.tidyverse.org/reference/aliases.html">extract2</a></span><span class="op">(</span><span class="st">"data"</span><span class="op">)</span> <span class="op">|&gt;</span></span>
<span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>color <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="va">beta</span><span class="op">[</span><span class="va">j</span><span class="op">]</span><span class="op">)</span><span class="op">)</span></span>
<span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>color <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="va">j</span><span class="op">)</span><span class="op">)</span></span>
<span> </span>
<span> <span class="va">plot</span> <span class="op">&lt;-</span></span>
<span> <span class="va">plot</span> <span class="op">+</span></span>
<span> <span class="fu">ggplot2</span><span class="fu">::</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_path.html">geom_path</a></span><span class="op">(</span></span>
<span> data <span class="op">=</span> <span class="va">data_j</span>,</span>
<span> <span class="fu">ggplot2</span><span class="fu">::</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html">aes</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">r</span>, y <span class="op">=</span> <span class="va">s</span>, color <span class="op">=</span> <span class="va">color</span><span class="op">)</span>,</span>
<span> linewidth <span class="op">=</span> <span class="fl">1</span></span>
<span> linewidth <span class="op">=</span> <span class="fl">0.75</span></span>
<span> <span class="op">)</span></span>
<span> <span class="op">}</span></span>
<span> </span>
<span> <span class="va">colors</span> <span class="op">&lt;-</span> <span class="fu">gg_color_hue</span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/length.html">length</a></span><span class="op">(</span><span class="va">beta</span><span class="op">)</span><span class="op">)</span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/names.html">names</a></span><span class="op">(</span><span class="va">colors</span><span class="op">)</span> <span class="op">&lt;-</span> <span class="va">beta</span> <span class="op">|&gt;</span> <span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="op">)</span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/names.html">names</a></span><span class="op">(</span><span class="va">colors</span><span class="op">)</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="va">beta</span><span class="op">)</span></span>
<span> </span>
<span> <span class="va">plot</span> <span class="op">&lt;-</span></span>
<span> <span class="va">plot</span> <span class="op">+</span></span>
Expand Down
Binary file modified docs/index_files/figure-html/unnamed-chunk-6-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/index_files/figure-html/unnamed-chunk-9-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"href": "index.html#overview",
"title": "SIR Model",
"section": "Overview",
"text": "Overview\nThis document focuses on demonstrating the SIR model, originally introduced by Kermack and McKendrick in (1927). The SIR model is a foundational framework in epidemiology, designed to analyze the spread of infectious diseases by categorizing the population into three compartments: Susceptible (S), Infected (I), and Recovered (R).\nThe dynamics of the model are represented by the following set of first-order, nonlinear differential equations:\n\\[\n\\begin{aligned}\n\\frac{dS}{dt} &= -\\beta S I \\\\\n\\frac{dI}{dt} &= \\beta S I - \\gamma I \\\\\n\\frac{dR}{dt} &= \\gamma I\n\\end{aligned}\n\\]\nHere, \\(\\beta\\) represents the transmission rate, and \\(\\gamma\\) is the recovery rate."
"text": "Overview\nThis document focuses on illustrating the SIR model, originally introduced by Kermack and McKendrick in (1927). The SIR model is a foundational framework in epidemiology, designed to analyze the spread of infectious diseases by categorizing the population into three compartments: Susceptible (S), Infected (I), and Recovered (R).\nThe dynamics of the model are represented by the following set of first-order, nonlinear differential equations:\n\\[\n\\begin{aligned}\n\\frac{dS}{dt} &= -\\beta S I \\\\\n\\frac{dI}{dt} &= \\beta S I - \\gamma I \\\\\n\\frac{dR}{dt} &= \\gamma I\n\\end{aligned}\n\\]\nwhere,\n\n\n\\(\\beta\\) represents the transmission rate;\n\n\\(\\gamma\\) represents the recovery rate."
},
{
"objectID": "index.html#setting-up-the-environment",
Expand Down Expand Up @@ -32,7 +32,7 @@
"href": "index.html#phase-space-visualization",
"title": "SIR Model",
"section": "Phase space visualization",
"text": "Phase space visualization\n\nCodegg_color_hue &lt;- function(n) {\n hues = seq(15, 375, length = n + 1)\n hcl(h = hues, l = 65, c = 100)[1:n]\n}\n\n\n\nCodeplot_phase_space &lt;- function(\n s = 1, \n i = 0.05, \n r = 0, \n beta = seq(3, 8, by = 1), \n lambda = 1, \n from = 0, \n to = 100,\n by = 0.01,\n theta = 180,\n phi = 0\n ) {\n checkmate::assert_number(s, lower = 0)\n checkmate::assert_number(i, lower = 0)\n checkmate::assert_number(r, lower = 0)\n checkmate::assert_numeric(beta)\n checkmate::assert_number(lambda)\n checkmate::assert_number(from, lower = 0)\n checkmate::assert_number(to, lower = from)\n checkmate::assert_number(by, lower = 0)\n checkmate::assert_number(theta, lower = 0)\n checkmate::assert_number(phi, lower = 0)\n\n colors &lt;- gg_color_hue(length(beta))\n plot &lt;-ggplot2::ggplot()\n \n for (j in seq_along(beta)) {\n data_j &lt;- \n sir(s, i, r, beta[j], lambda, from, to, by) |&gt;\n magrittr::extract2(\"data\") |&gt;\n dplyr::mutate(color = as.character(beta[j]))\n \n plot &lt;-\n plot +\n ggplot2::geom_path(\n data = data_j,\n ggplot2::aes(x = r, y = s, color = color),\n linewidth = 1\n )\n }\n \n colors &lt;- gg_color_hue(length(beta))\n names(colors) &lt;- beta |&gt; as.character()\n \n plot &lt;-\n plot +\n ggplot2::labs(\n title = \"SIR Model Phase-Space\",\n subtitle = latex2exp::TeX(\n paste0(\n \"$S_0$ = \", s, \" | \",\n \"$I_0$ = \", i, \" | \",\n \"$R_0$ = \", r, \" | \",\n \"$\\\\lambda$ = \", round(lambda, 2)\n ),\n ),\n x = \"Recovered\",\n y = \"Susceptible\"\n ) +\n scale_color_manual(\n name = latex2exp::TeX(\"$\\\\beta$\"), \n values = colors\n )\n \n print(plot)\n \n invisible()\n}\n\n\n\nCodeplot_phase_space()"
"text": "Phase space visualization\n\nCodegg_color_hue &lt;- function(n) {\n hues = seq(15, 375, length = n + 1)\n hcl(h = hues, l = 65, c = 100)[1:n]\n}\n\n\n\nCodeplot_phase_space &lt;- function(\n s = 1, \n i = 0.05, \n r = 0, \n beta = seq(3, 8, by = 1), \n lambda = 1, \n from = 0, \n to = 100,\n by = 0.01,\n theta = 180,\n phi = 0\n ) {\n checkmate::assert_number(s, lower = 0)\n checkmate::assert_number(i, lower = 0)\n checkmate::assert_number(r, lower = 0)\n checkmate::assert_numeric(beta)\n checkmate::assert_number(lambda)\n checkmate::assert_number(from, lower = 0)\n checkmate::assert_number(to, lower = from)\n checkmate::assert_number(by, lower = 0)\n checkmate::assert_number(theta, lower = 0)\n checkmate::assert_number(phi, lower = 0)\n\n plot &lt;-ggplot2::ggplot()\n \n for (j in beta) {\n data_j &lt;- \n sir(s, i, r, j, lambda, from, to, by) |&gt;\n magrittr::extract2(\"data\") |&gt;\n dplyr::mutate(color = as.character(j))\n \n plot &lt;-\n plot +\n ggplot2::geom_path(\n data = data_j,\n ggplot2::aes(x = r, y = s, color = color),\n linewidth = 0.75\n )\n }\n \n colors &lt;- gg_color_hue(length(beta))\n names(colors) &lt;- as.character(beta)\n \n plot &lt;-\n plot +\n ggplot2::labs(\n title = \"SIR Model Phase-Space\",\n subtitle = latex2exp::TeX(\n paste0(\n \"$S_0$ = \", s, \" | \",\n \"$I_0$ = \", i, \" | \",\n \"$R_0$ = \", r, \" | \",\n \"$\\\\lambda$ = \", round(lambda, 2)\n ),\n ),\n x = \"Recovered\",\n y = \"Susceptible\"\n ) +\n scale_color_manual(\n name = latex2exp::TeX(\"$\\\\beta$\"), \n values = colors\n )\n \n print(plot)\n \n invisible()\n}\n\n\n\nCodeplot_phase_space()"
},
{
"objectID": "index.html#references",
Expand Down
2 changes: 1 addition & 1 deletion docs/site_libs/bootstrap/bootstrap.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://danielvartan.github.io/sir/index.html</loc>
<lastmod>2024-09-19T13:25:31.076Z</lastmod>
<lastmod>2024-10-25T16:05:44.493Z</lastmod>
</url>
</urlset>
2 changes: 1 addition & 1 deletion index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ source(here::here("R/quarto-setup.R"))

## Overview

This document focuses on demonstrating the [SIR model](https://en.wikipedia.org/wiki/Compartmental_models_in_epidemiology), originally introduced by Kermack and McKendrick in [-@kermack1927]. The SIR model is a foundational framework in epidemiology, designed to analyze the spread of infectious diseases by categorizing the population into three compartments: Susceptible (S), Infected (I), and Recovered (R).
This document focuses on illustrating the [SIR model](https://en.wikipedia.org/wiki/Compartmental_models_in_epidemiology), originally introduced by Kermack and McKendrick in [-@kermack1927]. The SIR model is a foundational framework in epidemiology, designed to analyze the spread of infectious diseases by categorizing the population into three compartments: Susceptible (S), Infected (I), and Recovered (R).

The dynamics of the model are represented by the following set of first-order, nonlinear differential equations:

Expand Down
Loading

0 comments on commit e9a5bba

Please sign in to comment.