1
$\begingroup$

I have the next code:

sirds[[Alpha], [Beta], [Delta], [Mu]] := {S[t], SS[t], I[t], R[t], D[t]} /. First@NDSolve[{ S'[t] == -[Alpha]*S[t]*I[t] - [Delta]*SS[t], I'[t] == [Alpha]*S[t]*I[t] - [Beta]*I[t] - [Mu]*I[t], R'[t] == [Beta]*I[t], SS'[t] = [Delta]*SS[t], D'[t] == [Mu]*I[t], S[0] == 911000, I[0] == 22894, R[0] = 0, D[0] == 196, SS[0] = 0}, {[Alpha], [Beta], [Delta], [Mu]}, {t, 365}] Manipulate[Plot[ Evaluate[sirds[[Alpha], [Beta], [Delta], [Mu]]], {t, 0, 36}, PlotLegends -> {"Susceptible", "Vacunada", "Infectada", "Recuperada", "Muerta"}, Frame -> True, PlotRange -> {0, 50000}, PlotStyle -> { {Blue, Thickness[0.005]}, {Red, Thickness[0.005]}, {Green, Thickness[0.005]}, {Black, Thickness[0.005]}, {Yellow, Thickness[0.005]}}], {{[Alpha], .017428, "Infectividad"}, 0, .2}, {{[Beta], .3, "Recuperación"}, 0, .8}, {{[Delta], .0213577, "Letalidad"}, 0, .2}, {{[Mu], .002, "Eficacia"}, 0, .2}]

When I run it, it makes the table that I want, but it doesn't show the graphics that should show. Someone can help me? I took the same structure of this original code that runs perfectly:

sir[A_, B_, P_ ] := {a[t], f[t], r[t], d[t]} /. First@NDSolve[{ a'[t] == -Aa[t] f[t], r'[t] == Bf[t], d'[t] == Pf[t], f'[t] == Aa[t] f[t] - Bf[t] - Pf[t], a[0] == 478530 - 36, f[0] == 36, r[0] == 0, d[0] == 0}, {a, f, r, d}, {t, 112}] Manipulate[Plot[ Evaluate[sir[A, B, P]], {t, 0, 112}, PlotLegends -> {"Susceptible", "Infectada", "Recuperada", "Muerta"}, Frame -> True, PlotRange -> {0, 478530}, PlotStyle -> { {Blue, Thickness[0.005]}, {Red, Thickness[0.005]}, {Green, Thickness[0.005]}, {Black, Thickness[0.005]}}], {{A, .00000246, "Infectividad"}, 0, 2}, {{B, .69, "Recuperación"}, 0, 2}, {{P, .0111, "Letalidad"}, 0, 2}]

$\endgroup$

1 Answer 1

2
$\begingroup$

There are a very large number of syntax errors. The most serious relate to use of protected symbols: D, I.

This is a correction that should work. Please adjust plot range to your needs:

sirds[α_, β_, δ_, μ_] := {S[t], SS[t], i[t], 
   R[t], d[t]} /. 
  First@NDSolve[{S'[t] == -α*S[t]*i[t] - δ*SS[t], 
     i'[t] == α*S[t]*i[t] - β*i[t] - μ*i[t], 
     R'[t] == β*i[t], SS'[t] == δ*SS[t], 
     d'[t] == μ*i[t], S[0] == 911000, i[0] == 22894, R[0] == 0, 
     d[0] == 196, SS[0] == 0}, {S[t], SS[t], i[t], R[t], d[t]}, {t, 0,
      365}]
Manipulate[
 Plot[Evaluate[sirds[α, β, δ, μ]], {t, 0, 36},
   PlotLegends -> {"Susceptible", "Vacunada", "Infectada", 
    "Recuperada", "Muerta"}, Frame -> True, PlotRange -> {0, 50000}, 
  PlotStyle -> {{Blue, Thickness[0.005]}, {Red, 
     Thickness[0.005]}, {Green, Thickness[0.005]}, {Black, 
     Thickness[0.005]}, {Yellow, 
     Thickness[0.005]}}], {{α, .017428, "Infectividad"}, 
  0, .2}, {{β, .3, "Recuperación"}, 
  0, .8}, {{δ, .0213577, "Letalidad"}, 
  0, .2}, {{μ, .002, "Eficacia"}, 0, .2}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.