SIR model parameter fitting
显示 更早的评论
I want to find appropriate parameter i.e. beta.
First I have confirmed data for Jan.23~Dec.18.
I try to find best beta but result is same with inital guess beta. So I can't find how to do.
Here is my code.
I attach the data.
%% Data and current figure
clear; clc;
data_inc = readtable('inc_data2.csv','PreserveVariableNames',true);
date_inc = table2array(data_inc(:,1),'InputFormat','yyyy-MM-dd');
inc = table2array(data_inc(:,2));
% figure of incidence
figure(1)
bar(date_inc,inc)
%% data fitting
clc;
global beta gamma
beta = 0.01; gamma = 1/14;
parameter = [beta gamma];
IC1 = [880 10 0];
[t,y] = ode45(@SIR,[0,329],IC1);
plot(t,y);
%%
xdata = [1:1:329]';
ydata = inc;
x0 = parameter;
p = lsqcurvefit(@SIR,x0,[0,329],xdata,y,[0,0],[1,1]);
p
beta = 0.00001; % will change by lsqcurvefit result
gamma = 1/14;
IC2 = [beta gamma];
[t,y] = ode45(@SIR,[0,329],IC);
bar(xdata,inc)
hold on
plot(xdata,y(:,2));
hold off
%% plot
bar(xdata,inc)
hold on
plot(xdata,ydata,'r')
hold off
%% function
function dy = SIR(t,y)
global beta gamma
S = y(1); I = y(2);
dy = zeros(3,1);
dy(1) = -beta*S*I;
dy(2) = beta*S*I-gamma*I;
dy(3) = gamma*I;
end
回答(1 个)
yeongju han
2021-5-19
0 个投票
Heejin, Can I ask u something?
How did you success this code..? I am studying the SEIRDV model considering the introduction of vaccines.
l want update 'beta' by using lsqcurvefit. But, I can't update 'beta'.. Can you review my code..? or,, Can you share me the complete code? I'm so desperate.
(I'm Korean, too ^_^)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Computations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!