{"id":187,"date":"2022-01-28T20:10:23","date_gmt":"2022-01-28T20:10:23","guid":{"rendered":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/?p=187"},"modified":"2022-01-30T13:35:23","modified_gmt":"2022-01-30T13:35:23","slug":"stochastic-simulation-of-diseases-intro","status":"publish","type":"post","link":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/2022\/01\/stochastic-simulation-of-diseases-intro\/","title":{"rendered":"Stochastic Simulation of Diseases: Introduction and models"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>&#8220;I simply wish that, in a matter which so closely concerns the well-being of the human race, no decision shall be made without all the knowledge which a little analysis and calculation can provide&#8221;<\/p><cite>Daniel Bernoulli, 1760<\/cite><\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"a-brief-history-of-infectious-disease-modelling\">A brief history of Infectious Disease Modelling<\/h3>\n\n\n\n<p>In 1766, Swiss Mathematician Daniel Bernoulli published an article in the French literary magazine Mercure de France concerning the effect smallpox had on life expectancy and the improvements which could be made with the introduction of inoculation. Bernoulli\u2019s concluding argument, from which the aforementioned quote is derived, led to the creation of some of the first epidemiological models.<\/p>\n\n\n\n<p>This does not mean that the paper by Bernoulli was immediately lauded by his peers. Jean le Rond d\u2019Alembert was a prominent mathematician and intellectual at the time; albeit slightly behind the curve in probability theory, publishing in \u201cCroix ou Pile\u201d his rationale behind <a rel=\"noreferrer noopener\" href=\"https:\/\/www.cut-the-knot.org\/Probability\/dAlembert.shtml\" target=\"_blank\">believing the chance of attaining a head in a two toss game was 2\/3<\/a>. D\u2019Alembert clashed with Bernoulli on the issue, authoring a rebuttal in a 1760 paper \u201cOn the application of probability theory to the inoculation of smallpox\u201d.<\/p>\n\n\n\n<p>Bernoulli had initially communicated his work in a 1760 presentation in Paris. However, issues caused the paper to not be released until 1766, giving d\u2019Alembert a head start in his critique. He argued against some of the assumptions Bernoulli had made with respect to the probability of infections and the independence between age and dying of smallpox. D\u2019Alembert\u2019s alternative formulation also resembles modern modelling and, despite the differing opinions, both agreed that inoculation of the population was the way forward.<\/p>\n\n\n\n<p>Bernoulli\u2019s submission is often regarded as the foundation to what would eventually become <a rel=\"noreferrer noopener\" href=\"https:\/\/en.wikipedia.org\/wiki\/Mathematical_modelling_of_infectious_disease\" target=\"_blank\">mathematical epidemiology<\/a>, although the field as it is known today did not further develop until the early 20th century. This arrived in the form of work by the polymath <a href=\"https:\/\/www.nobelprize.org\/prizes\/medicine\/1902\/ross\/biographical\/\" data-type=\"URL\" data-id=\"https:\/\/www.nobelprize.org\/prizes\/medicine\/1902\/ross\/biographical\/\" target=\"_blank\" rel=\"noreferrer noopener\">Sir Ronald Ross<\/a>, who wrote on malaria prevention by crafting a model of <a rel=\"noreferrer noopener\" href=\"https:\/\/mathworld.wolfram.com\/OrdinaryDifferentialEquation.html\" target=\"_blank\">two differential equations<\/a>. More generalised models were also produced by William Kermack and Anderson McKendrick , their SIR model provided early forms of compartmental modelling; a class of models that form the cornerstone of much subsequent research. These models took a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Deterministic_system\" target=\"_blank\" rel=\"noreferrer noopener\">deterministic form<\/a> where no randomness is involved in the system and the output will always be replicated if given the same set of initial parameters.<\/p>\n\n\n\n<p>What we are more interested in are another class of compartmental models that arrived not too long after deterministic models: stochastic models. These types of models included the effects of randomness commonly found in real-life scenarios. There has been many approaches to these, each applicable to certain areas. We consider a few of these models in this blog post, all of which revolve around compartmentalising the population into key components: <strong>S<\/strong>usceptible, <strong>I<\/strong>nfected, and <strong>R<\/strong>ecovered individuals. The idea being you leave one state and filter into the next. Thus, under these basic assumptions, recovery can also mean recovering 6 feet under in a casket. But let\u2019s be positive and imagine all contractors of the hypothetical disease we discuss recover to live long and fruitful lives.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"chain-binomial-models\">Chain Binomial Models<\/h3>\n\n\n\n<p>We can try garner understanding of stochastic models through the introduction of a simple, probability based method in chain binomials.<\/p>\n\n\n\n<p>These models are discrete time (updates happen in an incremental step) and see where each fraction of the population is at the next time step. Some general yet subsequently quite restrictive assumptions are placed on the model. Namely:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>The population is fixed.<\/li><li>Disease will always transfer whenever contact is made.<\/li><li>Contacts are independent (two people cannot infect one individual).<\/li><li>Infected people recover one time step after infection.<\/li><\/ol>\n\n\n\n<p>Obviously in reality this is not likely to hold on large scale populations, however in small, enclosed environments such as Hospitals, Schools and Households, the use for this model becomes more relevant. <\/p>\n\n\n\n<p>So how does one model the movements between compartments? Say we infect <span class=\"wp-katex-eq\" data-display=\"false\">I_t<\/span> people at time <span class=\"wp-katex-eq\" data-display=\"false\">t<\/span>, then at the next time point we infect <span class=\"wp-katex-eq\" data-display=\"false\">I_{t+1}<\/span> people. These newly infected individuals will now leave the susceptible state by our assumption (2), and then by assumption (4), we must put the infectious people from the previous time step <span class=\"wp-katex-eq\" data-display=\"false\">t<\/span> into the recovered population. Mathematically we express this as:<\/p>\n\n\n\n<span class=\"wp-katex-eq katex-display\" data-display=\"true\">S_{t+1}=S_t-I_{t+1}<\/span>\n\n\n\n<span class=\"wp-katex-eq katex-display\" data-display=\"true\">R_{t+1}=R_t+I_{t}<\/span>\n\n\n\n<p>Now the most pertinent question is how do we govern the number of infections? You can perform some pretty elementary maths to arrive at the binomial distribution (<a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/BenSLowery\/Papers\/blob\/master\/StochasticModellingofEpidemics.pdf\" target=\"_blank\">for the curious page 18\/19 of my Master&#8217;s thesis covers this<\/a>). From a pool of <span class=\"wp-katex-eq\" data-display=\"false\">S_t<\/span> susceptible individuals, we find the probability of infecting <span class=\"wp-katex-eq\" data-display=\"false\">x<\/span> people given the probability of <em><strong>not<\/strong><\/em> infecting anyone is <span class=\"wp-katex-eq\" data-display=\"false\">q<\/span>. You can see why we phrase this last part in such a counterintuitive way shortly.<\/p>\n\n\n\n<p>Deterministic, or fixed updates, can be done by taking the expectation to find infections. Conversely, if you want to incorporate an air of chaos and randomness (and you actually read the title of this post), updates can also be done stochastically through a set of <a rel=\"noreferrer noopener\" href=\"https:\/\/mathworld.wolfram.com\/BernoulliTrial.html\" target=\"_blank\">Bernoulli trials<\/a>. <\/p>\n\n\n\n<p>The last step of the model is how to determine the average number of infections one infectious person is expected to give in this set up, or more commonly referred to as the basic reproduction number (<span class=\"wp-katex-eq\" data-display=\"false\">\\mathcal{R}_{0}<\/span>). Say we have a total population of <span class=\"wp-katex-eq\" data-display=\"false\">N<\/span>, then, <\/p>\n\n\n\n<span class=\"wp-katex-eq katex-display\" data-display=\"true\">\\mathcal{R}_0=(N-1)(1-q).<\/span>\n\n\n\n<p>The value <span class=\"wp-katex-eq\" data-display=\"false\">q<\/span>, which is used as a parameter in the binomial distribution to inform on the number of infections, can essentially be recovered from this reproduction number. To see chain binomial in action we can simulate an epidemic of <span class=\"wp-katex-eq\" data-display=\"false\">N=500<\/span> people and a <span class=\"wp-katex-eq\" data-display=\"false\">\\mathcal{R}_0=1.5<\/span>. <\/p>\n\n\n\n<p>Given the stochastic nature, it may be best to run multiple simulations as to not end up with potential anomalous results informing us incorrectly on what is likely to happen. Here, 7 iterations are chosen.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"554\" src=\"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-content\/uploads\/sites\/36\/2022\/01\/cb_reedfrost.png\" alt=\"\" class=\"wp-image-216\" srcset=\"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-content\/uploads\/sites\/36\/2022\/01\/cb_reedfrost.png 800w, https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-content\/uploads\/sites\/36\/2022\/01\/cb_reedfrost-300x208.png 300w, https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-content\/uploads\/sites\/36\/2022\/01\/cb_reedfrost-768x532.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><figcaption>Simulation of the chain binomial model&#8230; less said about this the better<\/figcaption><\/figure>\n\n\n\n<p>Here, given our large initial number of people, it can be seen that the chain binomial model dies out quickly with large populations and the discrete time steps lead to chunky graphs where conclusions are hard to be drawn. Therefore, this model is fairly weak and outdated to the task at hand, and it should come at no surprise that there are models that do perform better with larger populations, and a reaction based approach is considered next. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"gillespie-s-algorithm\">Gillespie&#8217;s Algorithm<\/h2>\n\n\n\n<p>Despite being initially formulated by the much cooler named Joseph Doob, the method was presented to the public forum by Dan Gillespie in 1976 an showcased a stochastic method to simulate the time evolution of a chemical system, through chemical reactions. This method can be <s>stolen<\/s> borrowed and applied to the epidemic setting through a re-evaluation of what these reactions can represent. <\/p>\n\n\n\n<p>We can think of the compartments we have defined earlier and how the movement between them can be thought of as reactions between states. More specifically, two &#8216;reactions&#8217; take place, an infection and a recovery. The former being a combination of a susceptible and infectious individual, and the latter being an infection contacting a recovery; which in this sense can be thought of as perhaps a healing ailment. For the algorithm itself, this <a rel=\"noreferrer noopener\" href=\"https:\/\/www.nature.com\/articles\/npre.2009.3673.1.pdf\" target=\"_blank\">poster<\/a> offers a neat overview of what&#8217;s at play and includes an epidemiological example. <\/p>\n\n\n\n<p>An interesting feature of this algorithm is its use of <a rel=\"noreferrer noopener\" href=\"https:\/\/mathworld.wolfram.com\/MonteCarloMethod.html\" target=\"_blank\">Monte Carlo<\/a> methods to dictate what reaction takes place, and its update states in a fraction of a time. This leads to both the stochastic nature we are looking for in these methods, as well as a more advantageous update strategy when compared to the often large discrete time updates with the previous chain binomial model.  <\/p>\n\n\n\n<p>It should be noted that with fixed fractional time updates, this method can be computationally expensive to implement, so a way to calculate more efficient time steps using <a rel=\"noreferrer noopener\" href=\"http:\/\/phelafel.technion.ac.il\/~filikas\/TAU.htm\" target=\"_blank\">tau-leaping<\/a> is preferred. An example using the same set up of 500 infectious individuals, but with a slightly higher reproduction number of <span class=\"wp-katex-eq\" data-display=\"false\">\\mathcal{R}_0=3<\/span>, to compare to the chain binomial is seen below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"554\" src=\"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-content\/uploads\/sites\/36\/2022\/01\/Gillespie-1.png\" alt=\"\" class=\"wp-image-220\" srcset=\"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-content\/uploads\/sites\/36\/2022\/01\/Gillespie-1.png 800w, https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-content\/uploads\/sites\/36\/2022\/01\/Gillespie-1-300x208.png 300w, https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-content\/uploads\/sites\/36\/2022\/01\/Gillespie-1-768x532.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><figcaption>A slightly better, if not still very variable simulation of an epidemic.<\/figcaption><\/figure>\n\n\n\n<p>Here, red, blue and green represent susceptible, infected and recovered individuals respectively, and the thick black lines give the trajectory of the epidemic if no randomness was involved. <\/p>\n\n\n\n<p>You can see the different trajectories (included for the same reason as the chain binomial to accompany for the effects of randomness and give us a fuller picture) vary greatly around the time of most infections, but all balance out towards the end. This method of evaluation is fairly good at epidemics on large scales, and the randomness feeds into why we&#8217;d want to use stochastic models in the first place&#8230;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"takeaways-and-further-investigations\">Takeaways and further investigations<\/h2>\n\n\n\n<p>The use of stochastic models might not be immediately obvious, from a naive point of view why would we want models that have the potential to deviate from what we expect to happen with fixed, deterministic models? In an idealised scenario where we play god, and have a clear view of how something will progress, then models that don&#8217;t factor in randomness is a clear and obvious avenue. However, this is never the case and has been seen extensively within the last few years that there is no way to truly model and predict the behaviour of humans and the rationale behind their decisions. So modelling contacts between groups and adding unpredictability in how it might happen show, even on a small simplified scale, the range of possibilities that could still potentially happen. Where deterministic models give an idea on what should happen given a set of assumptions, stochastic models provides what could if these fail or are effected by chance.<\/p>\n\n\n\n<p>This blog just scratches the surface of possible avenues in stochastic modelling of epidemics. Another big idea in this field is Stochastic Differential Equations based approaches, which uses ideas from Stochastic calculus and financial mathematics, a potential future blog post in the making. More on this, simulation of methods, sensitivity analysis and a use case relating to malaria, can be found in my MSc dissertation <a href=\"https:\/\/github.com\/BenSLowery\/Papers\/blob\/master\/StochasticModellingofEpidemics.pdf\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"references\">References<\/h3>\n\n\n\n<p>Linda J. S Allen is a rockstar of stochastic mathematical epidemiology, <a rel=\"noreferrer noopener\" href=\"http:\/\/today.ttu.edu\/posts\/2015\/07\/professor-awarded-distinguished-lecture-for-contributions-to-mathematics\" target=\"_blank\">even been awarded prizes for her work in the field<\/a>. She has produced the following concise tutorials, as well as length books on areas of stochastic epidemic modelling: <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>An Introduction to Stochastic Processes with Applications to Biology, CRC Press: <a href=\"http:\/\/www.routledge.com\/An-Introduction-to-Stochastic-Processes-with-Applications-to-Biology\/Allen\/p\/book\/9781439818824\" data-type=\"URL\" data-id=\"www.routledge.com\/An-Introduction-to-Stochastic-Processes-with-Applications-to-Biology\/Allen\/p\/book\/9781439818824\">www.routledge.com\/An-Introduction-to-Stochastic-Processes-with-Applications-to-Biology\/Allen\/p\/book\/9781439818824<\/a><\/li><li>An Introduction to Stochastic Epidemic Models, Springer Berlin Heidelberg, Berlin, Heidelberg, pp. 81\u2013130.<\/li><li>\u201cA primer on stochastic epidemic models: Formulation, numerical simulation, and analysis\u201d, Infect Dis Model 2(2), 128\u2013142.<\/li><\/ul>\n\n\n\n<p>For more on the history of epidemic models, and directions to the plethora of literature on the matter, the review article : \u201cHow mathematical epidemiology became a field of biology: a commentary on anderson and may (1981) \u2019the population dynamics of microparasites and their invertebrate hosts\u201d is an excellent read and is open access from here: <a href=\"https:\/\/royalsocietypublishing.org\/doi\/10.1098\/rstb.2014.0307\">https:\/\/royalsocietypublishing.org\/doi\/10.1098\/rstb.2014.0307<\/a>.<\/p>\n\n\n\n<p> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;I simply wish that, in a matter which so closely concerns the well-being of the human race, no decision shall be made without all the knowledge which a little analysis and calculation can provide&#8221; Daniel Bernoulli, 1760 A brief history of Infectious Disease Modelling In 1766, Swiss Mathematician Daniel Bernoulli published an article in the&hellip;&nbsp;<a href=\"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/2022\/01\/stochastic-simulation-of-diseases-intro\/\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Stochastic Simulation of Diseases: Introduction and models<\/span><\/a><\/p>\n","protected":false},"author":39,"featured_media":217,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"on","neve_post_elements_order":"[\"title\",\"meta\",\"thumbnail\",\"content\",\"tags\",\"comments\"]","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","slim_seo":{"title":"Stochastic Simulation of Diseases: Introduction and models - Ben Lowery @ STOR-i","description":"\"I simply wish that, in a matter which so closely concerns the well-being of the human race, no decision shall be made without all the knowledge which a little"},"footnotes":""},"categories":[5,4],"tags":[8,7,6,11,9],"class_list":["post-187","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mathematical-epidemiology","category-statistics","tag-epidemiology","tag-mathematics","tag-statistics","tag-stochastic-epidemic-models","tag-stochastic-simulation"],"_links":{"self":[{"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-json\/wp\/v2\/posts\/187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-json\/wp\/v2\/users\/39"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-json\/wp\/v2\/comments?post=187"}],"version-history":[{"count":33,"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-json\/wp\/v2\/posts\/187\/revisions"}],"predecessor-version":[{"id":226,"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-json\/wp\/v2\/posts\/187\/revisions\/226"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-json\/wp\/v2\/media\/217"}],"wp:attachment":[{"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-json\/wp\/v2\/media?parent=187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-json\/wp\/v2\/categories?post=187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ben-lowery\/wp-json\/wp\/v2\/tags?post=187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}