Filter löschen
Filter löschen

How to calculate one parameter in SIR model if we know the infinite condition?

2 Ansichten (letzte 30 Tage)
Hi all, say the question is we know the removal rate (v), the totoal poputation(N) and before this infection ceased there are x infected people, assuming that the infection degan with 1 infectious individuals, how to estimate beta if we use ode45?

Antworten (1)

Milan Bansal
Milan Bansal am 30 Mai 2024
Bearbeitet: Milan Bansal am 30 Mai 2024
Hi Xinyi Zhou
To estimate the transmission rate β of an infection using the SIR model (Susceptible, Infected, Recovered) using MATLAB's ode45 solver, you need to set up the differential equations and solve for β. Here's how you can approach it.
The SIR model is described by the following set of ordinary differential equations (ODEs):
Please refer to the steps given in the following code snippet below to estimate β:
%% 1.) Define Initial Conditions and Parameters (example values)
N = 1000; % Total population
I0 = 1; % Initial number of infected individuals
S0 = N - I0; % Initial number of susceptible individuals
R0 = 0; % Initial number of recovered individuals
v = 0.1; % Recovery rate
gamma = v; % Removal rate
x = 100; % Number of infected individuals before infection ceased
%% 2.) Define the SIR model ODEs
function dSIRdt = sir_model(t, SIR, beta, N, gamma)
S = SIR(1);
I = SIR(2);
R = SIR(3);
dS = -beta * S * I / N;
dI = beta * S * I / N - gamma * I;
dR = gamma * I;
dSIRdt = [dS; dI; dR];
end
%% 3.) Define a Time span
tspan = [0 160];
%% 4.) Set Initial conditions
SIR0 = [S0; I0; R0];
%% 5.) Define an Objective function to minimize
function error = objective(beta, tspan, SIR0, N, gamma, x)
[~, SIR] = ode45(@(t, SIR) sir_model(t, SIR, beta, N, gamma), tspan, SIR0);
I_end = SIR(end, 2); % Infected individuals at the end of the simulation
error = abs(I_end - x); % Error between simulated and observed infected individuals
end
%% 6.) Estimate beta using fminsearch function
beta_initial_guess = 0.3; % Initial guess for beta
beta_estimated = fminsearch(@(beta) objective(beta, tspan, SIR0, N, gamma, x), beta_initial_guess);
% Display the estimated beta
disp(['Estimated beta: ', num2str(beta_estimated)]);
Estimated beta: 0.13893
Please refer to the following documentation link to learn more about fminsearch function and ode45 solver.
Hope this helps.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by