Group Abstract Group Abstract

Message Boards Message Boards

Fit data with SIR model for epidemics?

Posted 7 years ago

Hello, I am completely new to Mathematica and am having problems with fitting my data to SIR model (modeling epidemics). I don't know how to fit two sets of data (cases and deaths) at once. There might be other mistakes also.

Clear[b, k, f, s, i, r, c, d, all, i0, r0];
tmax = 250.;
all = 100000.;
b = 0.255;
k = 0.2;
i0 = 1.;
r0 = 0.;

{s[t_], i[t_], r[t_]} = {s[t], i[t], r[t]} /.
   NDSolve[{
      s'[t] == -b*s[t]*i[t]/all,
      i'[t] == b*s[t]*i[t]/all - k*i[t],
      r'[t] == (k*i[t]),
      s[0] == all,
      i[0] == i0,
      r[0] == r0},
     {s, i, r}, {t, 0., tmax}][[1]];
f = 0.7;
c[t] == -s[t] + all;
d[t] == f*r[t];
Plot[{c, d}, {t, 0., tmax}]
data = Import["C:\\Users\\...\\Desktop\\NKP\\datafile.txt", 
   "Table"];
cases = data[[All, {1, 2}]];
deaths = data[[All, {1, 3}]];

(*Now I want to fit c[t] to cases and d[t] to deaths at the same time \
so I get one result for b,k and f each.*)
POSTED BY: Vita Hudi
POSTED BY: Tim Laska
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard