0
$\begingroup$

I'm trying to model an SIR model using the Manipulate function so that I can change the parameters. Although, when I enter in the following code:

μh = 0.05;
γm2 = 1/2;
funct1[λm_, 
b_, βh1m_, βh2m_, μm_, γm1_, δ_, \
λh_, βm1h_, βm2h_, γh_, ϕ_, 
q_, \[ScriptCapitalS]m0_, \[ScriptCapitalS]h0_] := 
funct1[λm, 
b, βh1m, βh2m, μm, γm1, δ, \
λh, βm1h, βm2h, γh, ϕ, 
q, \[ScriptCapitalS]m0, \[ScriptCapitalS]h0] = 
NDSolve[{\[ScriptCapitalS]m'[t] == λm - 
  b*βh1m*(\[ScriptCapitalS]m[
     t]*(Ιh1n[t] + Ιh1[
       t]))/Νh[t] - 
  b*βh2m*(\[ScriptCapitalS]m[
     t]*(Ιh2n[t] + Ιh2[
       t]))/Νh[t] - μm*\[ScriptCapitalS]m[
    t], Εm1'[t] == 
 b *βh1m (\[ScriptCapitalS]m[
     t]*(Ιh1n[t] + Ιh1[
       t]))/Νh[t] - γm1 *Εm1[
    t] - μm *Εm1[
    t] - δ *Εm1[t], Ιm1'[
  t] == γm1*Εm1[
    t] - μm*Ιm1[t] - δ*Ιm1[
    t], Εm2'[t] == 
 b*βh2m*(\[ScriptCapitalS]m[
     t]*(Ιh2n[t] + Ιh2[
       t]))/Νh[t] - γm2*Εm2[
    t] - μm*Εm2[
    t] + δ*Εm1[t], Ιm2'[
  t] == γm2*Εm2[
    t] - μm*Ιm2[t] + δ*Ιm1[
    t], \[ScriptCapitalS]h'[t] == λh - (
  b*βm1h*\[ScriptCapitalS]h[t]*Ιm1[
    t])/Νh[t] - (
  b*βm2h*\[ScriptCapitalS]h[t]*Ιm2[
    t])/Νh[
   t] - μh*\[ScriptCapitalS]h[t], Εh1'[t] == (
  b*βm1h*\[ScriptCapitalS]h[t]*Ιm1[
    t])/Νh[
   t] - (γh + μh)*Εh1[
    t], Ιh1n'[
  t] == (1 - ϕ)*γh*Εh2[
    t] - (q + μh)*Ιh1n[t], Ιh1'[
  t] == ϕ*γh*Εh1[
    t] - (q + μh)*Ιh1[t], 
Rh1'[t] == 
 q*(Ιh2n[t] + Ιh2[t]) - μh*
   Rh1[t], Εh2'[t] == (
  b*βm2h*\[ScriptCapitalS]h[t]*Ιm2[
    t])/Νh[
   t] - (γh + μh)*Εh2 [
    t], Ιh2n'[
  t] == (1 - ϕ)*γh*Εh2[
    t] - (q + μh)*Ιh2n[t], Ιh2'[
  t] == ϕ*γh*Εh2[
    t] - (q + μh)*Ιh2[t], 
Rh2'[t] == 
 q*(Ιh2n[t] + Ιh2[t]) - μh*
   Rh2[t], Νh[
  t] == \[ScriptCapitalS]h[t] + Ιh1n[
   t] + Ιh2n[t] + Εh2[
   t] + Εh1[t] + Rh1[t] + 
  Rh2[t], \[ScriptCapitalS]m[
  0] == \[ScriptCapitalS]m0, Εm1[0] == 
 0, Ιm1[0] == 1, Εm2[0] == 
 0, Ιm2[0] == 
 1, \[ScriptCapitalS]h[
  0] == \[ScriptCapitalS]h0, Εh1[0] == 
 0, Ιh1n[0] == 1, Ιh1[0] == 1, 
Rh1[0] == 0, Εh2[0] == 0, Ιh2n[0] == 
 1, Ιh2[0] == 1, 
Rh2[0] == 0}, {\[ScriptCapitalS]m[t], Εm1[
 t], Ιm1[t], Εm2[
 t], Ιm2[t], \[ScriptCapitalS]h[
 t], Εh1[t], Ιh1n[
 t], Ιh1[t], 
Rh1[t], Εh2[t], Ιh2n[
 t], Ιh2[t], Rh2[t]}, {t, 0, 100}]

and

Manipulate[
Plot[({\[ScriptCapitalS]m[x] /. 
 funct1[λm, 
  b, βh1m, βh2m, μm, γm1, δ, \
λh, βm1h, βm2h, γh, ϕ, 
  q, \[ScriptCapitalS]m0, \[ScriptCapitalS]h0], \
Εm1[x] /. 
 funct1[λm, 
  b, βh1m, βh2m, μm, γm1, δ, \
λh, βm1h, βm2h, γh, ϕ, 
  q, \[ScriptCapitalS]m0, \[ScriptCapitalS]h0], Ιm1[
  x] /. funct1[λm, 
  b, βh1m, βh2m, μm, γm1, δ, \
λh, βm1h, βm2h, γh, ϕ, 
  q, \[ScriptCapitalS]m0, \[ScriptCapitalS]h0], \
Εm2[x] /. 
 funct1[λm, 
  b, βh1m, βh2m, μm, γm1, δ, \
λh, βm1h, βm2h, γh, ϕ, 
  q, \[ScriptCapitalS]m0, \[ScriptCapitalS]h0], Ιm2[
  x] /. funct1[λm, 
  b, βh1m, βh2m, μm, γm1, δ, \
λh, βm1h, βm2h, γh, ϕ, 
  q, \[ScriptCapitalS]m0, \[ScriptCapitalS]h0], \
\[ScriptCapitalS]h[x] /. 
 funct1[λm, 
  b, βh1m, βh2m, μm, γm1, δ, \
λh, βm1h, βm2h, γh, ϕ, 
  q, \[ScriptCapitalS]m0, \[ScriptCapitalS]h0], \
Εh1[x] /. 
 funct1[λm, 
  b, βh1m, βh2m, μm, γm1, δ, \
λh, βm1h, βm2h, γh, ϕ, 
  q, \[ScriptCapitalS]m0, \[ScriptCapitalS]h0], Ιh1n[
  x] /. funct1[λm, 
  b, βh1m, βh2m, μm, γm1, δ, \
λh, βm1h, βm2h, γh, ϕ, 
  q, \[ScriptCapitalS]m0, \[ScriptCapitalS]h0], Ιh1[
  x] /. funct1[λm, 
  b, βh1m, βh2m, μm, γm1, δ, \
λh, βm1h, βm2h, γh, ϕ, 
  q, \[ScriptCapitalS]m0, \[ScriptCapitalS]h0], 
Rh1[x] /. 
 funct1[λm, 
  b, βh1m, βh2m, μm, γm1, δ, \
λh, βm1h, βm2h, γh, ϕ, 
  q, \[ScriptCapitalS]m0, \[ScriptCapitalS]h0], \
Εh2[x] /. 
 funct1[λm, 
  b, βh1m, βh2m, μm, γm1, δ, \
λh, βm1h, βm2h, γh, ϕ, 
  q, \[ScriptCapitalS]m0, \[ScriptCapitalS]h0], Ιh2n[
  x] /. funct1[λm, 
  b, βh1m, βh2m, μm, γm1, δ, \
λh, βm1h, βm2h, γh, ϕ, 
  q, \[ScriptCapitalS]m0, \[ScriptCapitalS]h0], Ιh2[
  x] /. funct1[λm, 
  b, βh1m, βh2m, μm, γm1, δ, \
λh, βm1h, βm2h, γh, ϕ, 
  q, \[ScriptCapitalS]m0, \[ScriptCapitalS]h0], 
 Rh2[x] /. 
 funct1[λm, 
  b, βh1m, βh2m, μm, γm1, δ, \
λh, βm1h, βm2h, γh, ϕ, 
  q, \[ScriptCapitalS]m0, \[ScriptCapitalS]h0]}), {x, 0, 100}, 
PlotRange -> All, 
PlotStyle -> {Red, Green, Blue, Yellow, Brown, Black, Red, Green, 
Blue, Yellow, Brown, Black, Red, Green}, PlotRange -> All, 
PlotLegends -> {\[ScriptCapitalS]m[t], Εm1[
 t], Ιm1[t], Εm2[
 t], Ιm2[t], \[ScriptCapitalS]h[
 t], Εh1[t], Ιh1n[
 t], Ιh1[t], 
Rh1[t], Εh2[t], Ιh2n[
 t], Ιh2[t], Rh2[t]}], {λm, 400, 5000}, {b, 
0.3, 1}, {βh1m, 0, 1}, {βh2m, 0, 1}, {μm, N[1/42], 
N[1/14]}, {γm1, N[1/6], N[1/2]}, {δ, 0, 
1}, {λh, 0, 1}, {βm1h, 0.01, 1}, {βm2h, 0.01, 
1}, {γh, 0, 1}, {ϕ, 0, 1}, {q, 0, 
1}, {\[ScriptCapitalS]m0, 1000000, 1500000}, {\[ScriptCapitalS]h0, 
1000000, 1500000}]

I just get a blank graph:

enter image description here

So I'm not really sure if the problem is how I defined the function, or if there are too many parameters being used? I'd really appreciate if someone could point out any mistakes that I've made, or let me know what else I could use that would also give me a plot where I can change the values of the parameters. I was also thinking about using ParametricNDSolveValue.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.