#SI和SIS模型
install.packages("EpiModel",dependencies = TRUE)
library(EpiModel)
#SI
param <- param.dcm(inf.prob = 0.2,act.rate = 0.25)#疫情参数通过PARAM传递到模型中,并根据需要添加其他参数。
#inf.prob:易感人群和在感染者之间的每次传播行为的感染概率。act.rate:每个人在单位时间内的平均传播行为数。
init <- init.dcm(s.num = 500, i.num = 1)
#s.num 初始易感染数。i.num 初始感染数。
control <- control.dcm(type ="SI", nsteps = 500)#通过控件传递到模型中的控件设置,并根据需要添加其他控件。
#nsteps模拟模型的时间步数。这必须是等于模拟的最后一步的正整数。
mod <- dcm(param, init, control)
plot(mod)
#SIS
param <- param.dcm(inf.prob = 0.2,act.rate = seq(0.25, 0.5, 0.05), rec.rate = 0.02)
#rec.rate免疫的平均恢复率(在SIR模型中)或再易感性(在SIS模型中)。
init <- init.dcm(s.num = 500, i.num = 1)
control <- control.dcm(type ="SIS", nsteps = 500)
mod <- dcm(param, init, control)
plot(mod, col = rainbow(3), lty = rep(1:2,each = 3), legend = "full")
#运行Shiny web应用程序
if (interactive()) {
epiweb("dcm")
epiweb("icm")
epiweb("net")
}