Virus Epidemics SIR Model - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP-41C Software Library (/forum-11.html) +--- Thread: Virus Epidemics SIR Model (/thread-14813.html) |
Virus Epidemics SIR Model - Ángel Martin - 04-08-2020 08:13 AM Chances are you're reading this from your "shelter in place" Covid-19 confinement, and thus will resonate with the concepts involved. This short program is a direct application of Jean-Marc Baillard's ODE routine "RK4C" from the Differential Equations module, available at TOS and the CL Library (id$ = "DIFF"). The SIR model calculates the values of Susceptible, Infected and Removed groups of population in a total population of N individuals. N = S + I + R. The virus is modeled with two parameters that indicate the infection rate "a" and the recovery rate "b". These are the crux of the model, as they need to be expressed in the same units used by the ODEs to show the individual results - i.e. a=2.3 infected people per person and DAY, and b = 0.3 people recovered per DAY if we want to look at daily numbers. Supposedly your local Covid-19 statistics could be used to estimate the parameters, but this is tricky since the reported infection cases are much lower than the actual ones. Besides, the Removed section includes both the recovered (cured) and the dead patients. The ODEs are normalized by the total population size N, but this is transparent to the user and it's done by the routine itself. The ODE's are implemented in the LBL "d/dt" subroutine: dS/dt = -a. I(t).S(t) dI/dt = a. S(t). I(t) - b.I(t) dR/dt = b.I(t) So here you have it, play with your a,b parameters (XEQ A) and define your initial conditions N, So, Io (XEQ B) to start getting the results for the S,I,R sectors of population. The model assumes Ro=0. Remember that N=S+I+R at all times. Program Listing: Code: 9:41AM 04/08 Note: ARCLI is in the AMC_OS/X Module. It appends the integer part o X to ALPHA. PS. Looks that the formatting codes don't work within a CODE block? PSS. - SIR material abounds on the Web, here's one video that was useful to me to grasp some details: https://www.youtube.com/watch?v=k6nLfCbAzgo&t=867s RE: Virus Epidemics SIR Model - Geoff Quickfall - 04-08-2020 03:56 PM Interesting info Angel. I will get it installed and start playing with it. Under COVID a new definition of R (recovered) has been proposed. Actually it has been an alternative for years. R = removed (not recovered) as a death affects R in the same manner as recovered; both removing and no longer infected or susceptible. RE: Virus Epidemics SIR Model - Ángel Martin - 04-09-2020 12:24 AM (04-08-2020 03:56 PM)Geoff Quickfall Wrote: Under COVID a new definition of R (recovered) has been proposed. Actually it has been an alternative for years. Yes, that's exactly how it's labeled in this model, see text: "The SIR model calculates the values of Susceptible, Infected and Removed groups of population in a total population of N individuals. N = S + I + R." and: "Besides, the Removed section includes both the recovered (cured) and the dead patients." The attached RAW file should facilitate things. RE: Virus Epidemics SIR Model - SlideRule - 04-09-2020 12:39 PM " An Epidemic Model The SIR model is a simple model, due to Kermack and McKendrick, of an epidemic of an infectious disease in a large population. We assume the population consists of three types of individuals, whose numbers are denoted by the letters S, I and R (which is why this is called an SIR model). All these are functions of the time t, and they change according to a system of differential equations. • S is the number of susceptibles, who are not infected but could become infected. • I is the number of infectives. These individuals have the disease and can transmit it to the susceptibles. • R is the number of removed individuals. These may or may not have the disease, but they can't become infected and they can't transmit the disease to others. They may have a natural immunity, or they may have recovered from the disease and are immune from getting it again, or they may have the disease but are incapable of transmitting it (e.g. because they may have been placed in isolation), or they may have died. The mathematical model doesn't distinguish among those possibilities. The model we will consider assumes a time scale short enough that births and deaths (other than deaths from this disease) can be neglected." [attachment=8324] a visualization Might I recommend The Mathematical Theory of Infectious Diseases and its application, 2e (ISBN 0 85264 231 8) BEST! SlideRule ... je souhaite seulement que dans une question qui regarde de si près le bien de l'humanité, on ne décide rien qu'avec toute la connoissance de cause qu'un peu d'analyse & de calcul peut fournir. Daniel Bernoulli, 1760 RE: Virus Epidemics SIR Model - Ángel Martin - 04-15-2020 11:55 AM (04-09-2020 12:24 AM)Ángel Martin Wrote: The attached RAW file should facilitate things. RAW file removed - it's been replaced by a new ROM with the SIR model using ODEs plus a direct method using a combined SOLVE/INTEG for numerical evaluation... Edited: Here it is, make sure both MOD files are plugged to use the direct method (LBL "R<T>") as both FINTG and FROOT are used. Most recommendable to use TURBO mode in V41 (or a CL w/ Turbo50) due to the slow numerical process involved. The ODE-based method is accessed with LBL "SIR" (general population size N) and LBL "SIR2+" (unitary population size N=1, i.e. ratios for S, I, and R). Thanks to Jean-Marc for his suggestions and contributions to this module. RE: Virus Epidemics SIR Model - Ángel Martin - 04-20-2020 10:28 AM Updated MOD file is attached, it now offers two versions for the direct method: 1. LBL "R=RT" - using FOCAL routines for Solve & Integ, self-contained 2. LBL "R<T>", using FINTG and FROOT in the Solve & Integrate ROM The SIR model also has two versions as follows: 1. LBL "SIR", population N 2. LBL "SIR2+", population N=1 A few additional routines are thrown in as well, such as EASTER - written by Kari Passanen, the EKG Calculations , the LDL Cholesterol formula and the totally unrelated Audio Tape Counter programs from the forum. |