Keywords
Compartmental Models, Numerical Simulation, Matlab software codes, R software codes
This article is included in the Bioinformatics gateway.
Compartmental Models, Numerical Simulation, Matlab software codes, R software codes
With the help of a programming language that represents matrix and array mathematics directly, MATLAB combines a desktop environment tailored for iterative analysis and design processes.1 The Live Editor for writing scripts that mix code, output, and formatted text in an executable notebook is part of it.1 The Windows requirements are Windows 10 (version 20H2 or higher), Windows 11, Windows Server 2019, and Windows Server 2022. Many scientists and mathematicians choose to use this program since it can be accessed across all popular platforms, including Linux, Mac, and Windows, and because it can be used to explore, model, and analyze data.1 Matlab software has been used to run numerical simulations of compartmental models in epidemiology.2–11
There are several fundamental compartmental models described using differential equations. The basic ones include Susceptible - Infected (SI), Susceptible - Infected - Recovered (SIR),12,13 Susceptible - Infected - Susceptible (SIS),14 Susceptible - Infected - Recovered - Vaccinated (SIRV),15 Susceptible - Exposed - Infected - Recovered (SEIR) models.4 The purpose of this study is to make public new Matlab codes that authors have been utilising in their work to aid researchers, especially students, who rely on deterministic or compartmental modeling of epidemiology in the numerical simulation of their research projects. This well-detailed code, in our opinion, might be extremely helpful to them as many of them struggle to do the numerical simulations due to the dearth of research that specifically tackles numerical simulation of deterministic models and also to provide users more freedom for coding in Matlab. Recently, researchers have started sharing their codes and providing detailed explanation on how to use them. To provide users extra coding freedom, Guo et al.16 presented newly developed visualization framework called OpenSeesPyView, which is a Python programming-based graphical user interface (GUI) for OpenSeesPy, a prevalent finite element solver in earthquake engineering. The R package ag5Tools was written by Brown et al.17 and offers a streamlined interface for downloading and retrieving AgERA5 data. With the help of the program, time-series data for groups of geographic points may be easily extracted and converted into a format that can be employed in statistical models used in agricultural research. The Rcall interface, developed by Egert and Kreutz,18 gives users access to a large range of techniques written in MATLAB and R. The program is MATLAB-based and offers direct access to R-based tools and methodologies, such as those found on Bioconductor or CRAN. ShinyGAStool, an open source tool created by Hoffmann et al.,19 allows users to easily execute a candidate gene association analysis from a web browser using huge datasets. The remaining section are group as follows: The method section, where we demonstrate how to use the Matlab software codes. we look at the implementation, operation and discussions and limitations. The last section is the concluding section. The software section has the alternative software codes in R.
We demonstrate how to use the matlab software codes with the SEIR compartmental model depicted in Figure 1. The population is partitioned into four (4) compartments: Susceptible, exposed, infected and recovered. Individuals are recruited into the susceptible class at a rate and they die at a rate . The transmission rate is and the recovery rate is . The rate at which exposed individuals become infectious is and the disease-induced death rate is .
The model is described by the following ordinary differential equations.
For the purposes of the simulations, the following parameter values are chosen and is given in Table 1. The initial conditions chosen are
Parameter | Description | Value | Source |
---|---|---|---|
Recruitment | 29.08 | 2 | |
Transmission rate | 0.9 | 2 | |
infectiousness of the exposed individuals | 0.3 | assumed | |
natural rate of death | 0.4252912 | 2 | |
Recovery rate of infected individuals | 0.1 | assumed | |
Disease-induced death rate | 0.003286 | assumed |
Once you have your model and parameter values clearly defined, you can then open the matlab editor window which is shown in Figure 2. Input or copy the codes and paste at the new script.
The numerical Matlab software codes used for model (1)
if nargin==0
MaxTime=120; % The MaxTime stands for the duration of the simulation
end
N=S+E+I+R;
% The main iteration
options=odeset(’RelTol’,1e-5);
% plots the graphs with scaled colours
figure(1)
Y=plot(t,S,’b.’);
legend(Y,’Susceptible’)
xlabel’Time (days)’
ylabel’S(t)’
figure(2)
T=plot(t,E,’.g’);
legend(T,’Exposed’)
xlabel’Time (days)’
ylabel’E(t)’
figure(3)
f=plot(t,I,’.m’);
legend(f,’Infected’)
xlabel’Time (days)’
ylabel’I(t)’
figure(4)
h=plot(t,R,’.g’);
legend(h,’Recovered’)
xlabel’Time (days)’
ylabel’R(t)’
% calculates the differential rates used in the integration.
Upon running the codes, some of the simulation results are shown in Figures 3–6.
In Figures 3–6, are reported, the numerical solutions of system (1) for a period of 120 days. These codes can be modified for any compartmental models. The ‘figure’ command produces the output given in Figures 3–6. The steps or procedures listed in the codes have to be followed carefully in order not to encounter errors. The parameters can be represented with letters for instance can be written in the codes as Omega as Matlab doesn’t recognize the parameters listed in the code. The code written in the editor window can be seen in Figure 7. The SEIR model is extended, and an alternative software, R codes has been provided at the appendix section. Using the same initial conditions and parameter values given in Table 1, the output figures for the R code are given by Figures 8–10. Users who cannot afford Matlab software can freely use the R software codes for the numerical simulation. The two software codes gives the same output results.
MATLAB can disable some advanced graphics rendering features by switching to software OpenGL by ignoring extra legend entries.
R on the other hand, has a limited memory capacity which can be a problem when working with large data sets or running computationally-intensive analyses. It can be relatively slow compared to other programming languages like Matlab, C++ or Python, especially for certain types of calculations. It also has limited graphical capabilities.
This work seeks to introduce new matlab software codes purposely for numerical simulations of classical compartmental models which can run on any version of Matlab. The intended targets are researchers and students who uses Matlab for their analysis. This codes can be edited/modify to suit any deterministic models and any desire output required. The SEIR deterministic model was used to give a much insight about the codes. Alternatively, a deterministic SEIR codes written in R software is provided for those who wants to use freely available software. Despite the limitations of the R software, the deterministic model implemented in the R code can still be a useful tool for understanding the basic dynamics of disease transmission.
OSF: Raw_data_monkeypox. DOI: 10.17605/OSF.IO/2J5R9.
This project contains the following underlying data:
Data_used.pdf (data input into matlab simulations)
OSF: Output_data DOI: 10.17605/OSF.IO/7EJUP.
This project contains the following extended data:
MATLAB Command Window1.pdf (Matlab output data that accompanied the numerical simulation figures)
Data are available under the terms of the Creative Commons Zero “No rights reserved” data waiver (CC0 1.0 Public domain dedication).
Source code available from: https://github.com/okyere2015/Matlab_codes/releases/tag/v2.0.1.
Archived source code at the time of publication: https://doi.org/10.5281/zenodo.7671815.
License: Apache 2.0
Views | Downloads | |
---|---|---|
F1000Research | - | - |
PubMed Central
Data from PMC are received and updated monthly.
|
- | - |
Is the rationale for developing the new software tool clearly explained?
Partly
Is the description of the software tool technically sound?
Yes
Are sufficient details of the code, methods and analysis (if applicable) provided to allow replication of the software development and its use by others?
Partly
Is sufficient information provided to allow interpretation of the expected output datasets and any results generated using the tool?
Partly
Are the conclusions about the tool and its performance adequately supported by the findings presented in the article?
Partly
Competing Interests: No competing interests were disclosed.
Reviewer Expertise: Numerical Analysis, Mathematical Modelling, Mathematical Biology and Epidemiology.
Is the rationale for developing the new software tool clearly explained?
Yes
Is the description of the software tool technically sound?
Yes
Are sufficient details of the code, methods and analysis (if applicable) provided to allow replication of the software development and its use by others?
Yes
Is sufficient information provided to allow interpretation of the expected output datasets and any results generated using the tool?
Partly
Are the conclusions about the tool and its performance adequately supported by the findings presented in the article?
Yes
Competing Interests: No competing interests were disclosed.
Reviewer Expertise: Mathematical modeling
Alongside their report, reviewers assign a status to the article:
Invited Reviewers | ||
---|---|---|
1 | 2 | |
Version 2 (revision) 25 Sep 23 |
read | read |
Version 1 26 Apr 23 |
read | read |
Provide sufficient details of any financial or non-financial competing interests to enable users to assess whether your comments might lead a reasonable person to question your impartiality. Consider the following examples, but note that this is not an exhaustive list:
Sign up for content alerts and receive a weekly or monthly email with all newly published articles
Already registered? Sign in
The email address should be the one you originally registered with F1000.
You registered with F1000 via Google, so we cannot reset your password.
To sign in, please click here.
If you still need help with your Google account password, please click here.
You registered with F1000 via Facebook, so we cannot reset your password.
To sign in, please click here.
If you still need help with your Facebook account password, please click here.
If your email address is registered with us, we will email you instructions to reset your password.
If you think you should have received this email but it has not arrived, please check your spam filters and/or contact for further assistance.
Comments on this article Comments (0)