Install and load the package deSolve
. Take a look at the first example of the documentation of ode()
.
The ODEs of the SIR model, \(\dot{\vec x} = f(\vec x)\), are given by: \[ \begin{align} \dot{S}(t) & = - r \cdot S(t) \cdot I(t), \\ \dot{I}(t) & = r \cdot S(t) \cdot I(t) - a \cdot I(t), \\ \dot{R}(t) & = a \cdot I(t), \end{align} \] where \(\mathbb{R} \ni t \mapsto S(t),I(t),R(t) \in \mathbb{R}\) and the parameters \((a, r) \in \mathbb{R}_{+}^2\) are positive.
SIR <- function(time, ini, pars)
that can be passed as func
argument to ode()
. Add two functions out2config <- function(out, parameter)
and out2phase <- function(out, parameter)
that arrange the output of ode()
in a config or phase space data.frame
with columns:
time, value, species, parameter
, where species
\(\in \{S,I,R\}\) and parameter
, labelling the parameter choice, are character
variables.S, I, R, parameter
.ode()
to integrate the system for \(r = 0.1\); \(a=50\) and the initial values \(R(t=0) = 0\), \(S(t=0) = 450\), \(N = R(t=0) + S(t=0) + I(t=0) = 1000\).
dI
as a function of \(I(t=0)\).dI
using uniroot
.a
and r
for \(N = 1000\), \(S(t=0)=950\), \(R(t=0)=0\).
Imax
, the maximal value of \(I(t)\), in a 2d grid plot via geom_tile()
annotate("line",...)
Close to the outside staircase leading to the top panorama platform there are seven huge figures. During the renovation around 1900 one of the figures was replaced by a figure of the Canon. What about this fact was so funny for a church representative from Konstanz when he visited the inauguration ceremony after the renovation?