在疫情防控的科学研究中,传统的 SIR 模型虽然经典,但无法满足对复杂传播过程的精确描述。今天我们将深入探讨一个更精细的传染病模型 ——SEIRD 模型,它不仅区分了不同结局的感染者,还考虑了免疫力随时间消退的重要因素。通过 MATLAB 代码实现,我们将揭示这种更贴近现实的模型如何帮助我们理解传染病的长期传播规律。
SEIRD 模型将人群细分为 6 个类别:
模型通过以下参数描述传播过程:
SEIRD 模型的核心是一组差分方程,描述各状态间的转移关系:
\(\begin{aligned} S_{t+1} &= S_t - \beta S_t \frac{I_{R,t} + I_{D,t}}{N_t} + \omega R_t \\ E_{t+1} &= E_t + \beta S_t \frac{I_{R,t} + I_{D,t}}{N_t} - \delta E_t + \epsilon \\ I_{R,t+1} &= I_{R,t} + \delta (1-\mu) E_t - \gamma_R I_{R,t} + \epsilon \\ I_{D,t+1} &= I_{D,t} + \delta \mu E_t - \gamma_D I_{D,t} + \epsilon \\ R_{t+1} &= R_t + \gamma_R I_{R,t} - \omega R_t \\ D_{t+1} &= D_t + \gamma_D I_{D,t} \end{aligned}\)
这些方程体现了模型的核心逻辑:
% SEIRD模型参数设置
S_ini = 1e6; % 初始易感人数
E_ini = 1; % 初始潜伏期人数
beta = 0.3; % 感染率
delta = 0.2; % 潜伏期倒数
gamma_R = 0.2; % 康复率
gamma_D = 0.4; % 死亡率
mu = 0.05; % 病死率
omega = 1; % 免疫力消退率
epsilon = 0.01; % 输入病例率
% 时间与模拟设置
t_steps = 0:2000;
num_simulations = 25; % 多次模拟捕捉随机性
代码使用随机抽样模拟状态转移:
% 主模拟循环
for sim = 1:num_simulations
for t = 1:num_time_points-1
% 获取当前状态
current_S = S(t, sim);
current_E = E(t, sim);
current_Ir = Ir(t, sim);
current_Id = Id(t, sim);
current_R = R(t, sim);
current_D = D(t, sim);
% 计算感染压力和总人口
I = current_Ir + current_Id;
N = current_S + current_E + I + current_R + current_D;
% 处理零人口情况
p_SE = (N > 0) ? 1 - exp(-beta * I / N) : 0;
% 计算转移概率
p_EI = 1 - exp(-delta);
p_IrR = 1 - exp(-gamma_R);
p_IdD = 1 - exp(-gamma_D);
p_RS = 1 - exp(-omega);
% 随机抽样转移人数
n_SE = binornd(current_S, p_SE); % 易感转暴露
n_EI = binornd(current_E, p_EI); % 暴露转感染
% 区分感染者结局
if n_EI > 0
n_EIrId = mnrnd(n_EI, [1-mu, mu]); % 多项分布抽样
n_EIr = n_EIrId(1); % 转康复组
n_EId = n_EIrId(2); % 转死亡组
else
n_EIr = 0; n_EId = 0;
end
% 其他状态转移
n_IrR = binornd(current_Ir, p_IrR); % 康复
n_IdD = binornd(current_Id, p_IdD); % 死亡
n_RS = binornd(current_R, p_RS); % 免疫消退
n_import_E = poissrnd(epsilon); % 外部输入
% 更新状态并确保非负
S(t+1, sim) = max(current_S - n_SE + n_RS, 0);
E(t+1, sim) = max(current_E + n_SE - n_EI + n_import_E, 0);
Ir(t+1, sim) = max(current_Ir + n_EIr - n_IrR, 0);
Id(t+1, sim) = max(current_Id + n_EId - n_IdD, 0);
R(t+1, sim) = max(current_R + n_IrR - n_RS, 0);
D(t+1, sim) = max(current_D + n_IdD, 0);
end
end
这段代码通过随机抽样实现了模型的随机性:
binornd
模拟离散事件(如感染、康复)mnrnd
模拟感染者的不同结局poissrnd
模拟外部病例输入代码绘制了所有状态变量随时间的变化:
% 绘制结果
figure;
hold on;
for i = 1: num_simulations
plot(t_steps, S(:, i), 'LineWidth', 2, 'DisplayName', 'Susceptible');
plot(t_steps, E(:, i), 'LineWidth', 2, 'DisplayName', 'Exposed');
plot(t_steps, Ir(:, i), 'LineWidth', 2, 'DisplayName', 'Infected (Recovering)');
plot(t_steps, Id(:, i), 'LineWidth', 2, 'DisplayName', 'Infected (Dying)');
plot(t_steps, R(:, i), 'LineWidth', 2, 'DisplayName', 'Recovered');
plot(t_steps, D(:, i), 'LineWidth', 2, 'DisplayName', 'Deceased');
end
xlabel('Time (days)');
ylabel('Number of individuals');
title('SEIRD Model Simulation');
legend('S', 'E', 'Ir', 'Id', 'R', 'D', 'Location', 'best');
grid on;
通过分析模拟结果,我们可以观察到:
SEIRD 模型可以帮助决策者评估:
通过调整参数,可以研究:
SEIRD 模型通过细分感染状态和考虑免疫消退,为我们提供了更贴近现实的传染病传播图景。在面对 COVID-19 等具有长期流行潜力的疾病时,这类模型尤为重要。通过随机模拟,我们不仅能捕捉疫情的平均趋势,还能评估不确定性带来的风险。
互动话题:你认为 SEIRD 模型还可以在哪些方面进一步优化?欢迎在评论区分享你的见解!