Move quickly from one page to another within COVID-19 Series from MATLAB Helper:
As we have discussed in the other SIR Modelling posts, SIR model has only a few tunable parameters. For this case we have selected these ones:
Wait! What happens with ???? and ? Sorry, we don't know what their values are. So?
So, let's compute them! This approach includes an algorithm for doing calculations for ???? and ????. We will only need the real data for Odisha.
Estimating ???? and ???? :
% Author: Abhishek Agrawal
% Topic : SIR Modeling using MATLAB
% Company: MATLAB Helper
% Website: https://MATLABHelper.com
% Date : 31-05-2020
% With the help of this script we will plot the actual and the predicted data on COVID-19 cases in ODISHA OR.
%% Clearing the command window and workspace and close all other tabs
%% Importing the data i.e. COVID-19 cases
% Initial confirmed and recovered cases
% creating the cumilative confirmed and recovered cases arrays for Odisha OR
confirmed (j) =0;
recovered (j) =0;
confirmed (j+1) =confirmed(j)+raw.OR(i);
recovered (j+1) =recovered(j)+raw.OR(k)+ raw.OR(m);
%% SIR parameters i.e. Betta and Gamma Calculation
% Declaring beta and gamma as global variable
% Total exposed population in ODISHA
% Taking the day as 1 i.e. step size for calculation on daily basis
What does this part of the code mean? Well, First, we use webread for collecting the data. It contains information about susceptible, recovered and infected people for all states of India. This information will be stored in raw variable. So, we need data of Odisha, for getting the data, we use raw.OR (where OR refers to Orissa now known as Odisha). Then we set the population (N), and then we define the variables Beta and Gamma, which will be computed.
Then, a while loop is used to separate the data in infected, recovered, and finally susceptible people. Once it is done. Finally beta and Gamma are computed like as shown with the code below:
beta(i) =(susceptible(i)-susceptible(i+1))/(susceptible(i).*infected(i)*dt ) ;
% Calculation of parameter Gamma
gamma(i) =(recovered(i+1)-recovered(i))/( infected(i)*dt ) ;
Building and Plotting SIR model :
Now we know all the model’s parameters, we are building and plotting the SIR model. Let's consider these functions:
function result = f(u,t)
S = u(1); I = u(2); R = u(3);
result = [-beta*S*I beta*S*I-gamma*I gamma*I];
The 'result' function is built to represent the SIR model, which is to say, the three differential equations. u variable contains the information about Susceptibles (u(1)), Infected (u(2),) and Recovered (u(3)). Finally, we have the equations which will be needed for the output of the model.
function [u, t] = ode_FE(f, U_0, dt, D)
u = zeros(D+1, length(U_0));
t = linspace(0, D*dt, length(u));
u(1,:) = U_0; % Initial values
t(1) = 0;
for n = 1:D
u(n+1,:) = u(n,:) + dt*f(u(n,:), t(n));
Now,ode_FEfunction computes the next-step values for the Susceptibles, infected and recovered individuals. For this, we need the model (f), initial conditions (U_0), simulation step (dt) which represents days, and finally the total amount of simulation steps (D) which in this case has been defined as 365 days.
Now, let us plot the results. First, we define dt and D as explained previously. Next, the initial values are defined, and using ode_FE we compute SIR values!
% showing the Simulation for D days
D = 365;
% initial values for susceptible, infected and recovered cases
U_0 = [susceptible(l) infected(l) recovered(l)];
% Differential equations for calculation of future cases
f_handle = @f;
[u, t] = ode_FE(f_handle, U_0, dt, D);
S = u(:,1);
I = u(:,2);
R = u(:,3);
%% Ploting the predicted data
plot(t, S, 'b-', t, I, 'y-', t, R, 'g-')
%% Ploting the actual data
% Inorder to make the length of actual and prdicted data equal assigned other values as NaN
susceptible(end+1:D+1) = nan;
infected(end+1:D+1) = nan;
recovered(end+1:D+1) = nan;
legend('Predicted-S', 'Predicted-I', 'Predicted-R','Actual-S', 'Actual-I', 'Actual-R');
Finally, real data is plotted and compared with the predicted data of the SIR model.
Now in the next blog, we will be doing analysis for a different nation, Colombia.
We have used data untill 31st May 2020 for all these analysis. We have seen some approaches to modelling diseases such as COVID-19 through MATLAB. We have found essential characteristics within this process. We have done Data Analysis and Data Extraction and included a reliable source for the COVID-19 data. We have used preprocessing to extract a subset of the collected data and organise the data accurately. We have done Data Modelling with model construction, i.e. finding the best model that fits the COVID-19 pandemic. We have done the calculation of model parameters using real collected data and finally done the Data Visualisation. All these steps were essential, and luckily, MATLAB has so many functions and tool to use in the given scenario.
Now summing our analysis and coming to a definite conclusion, India's COVID-19 case tally climbed from 100 to one lakh in just 64 days as per the data sourced from the Union Ministry of Health & Family Welfare (MoHFW). On comparing this with global data, sourced from Worldometers, it has been found out that India's COVID-19 growth rate is more than double the number of days as compared to Colombia.
Our COVID-19 codes and analysis have been made for educational and research purpose. We have shown different approaches of Pandemic Modelling for each state and the accuracy of result is not guaranteed for real-life situation. We wish for early end of this pandemic. Now it's in our hands; we need to take our responsibilities & take proper precautions.
Now let's have a quick view of the precautions.
If you have been facing the symptoms of Cold and Cough or the one's shown with COVID-19, then self-isolate yourself with home quarantine for 14 days. So stay home stay safe; this is the best way you can contribute to the betterment of the nation.