- https://www.mathworks.com/help/matlab/ref/fminsearch.html
- https://www.mathworks.com/help/matlab/ref/ode45.html
How to calculate one parameter in SIR model if we know the infinite condition?
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?
0 件のコメント
回答 (1 件)
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)]);
Please refer to the following documentation link to learn more about fminsearch function and ode45 solver.
Hope this helps.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!