필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Xinyi Zhou
Xinyi Zhou 2021년 3월 28일
편집: Milan Bansal 2024년 5월 30일
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?

답변 (1개)

Milan Bansal
Milan Bansal 2024년 5월 30일
편집: Milan Bansal 2024년 5월 30일
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.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by