R for modellers - Vignette 12

Fitting an ODE

Julien Arino

Department of Mathematics

University of Manitoba*




* The University of Manitoba campuses are located on original lands of Anishinaabeg, Cree, Oji-Cree, Dakota and Dene peoples, and on the homeland of the Métis Nation.

Principle - Fitting data

Fitting data

Principle

  • Data is a set \((t_i,y_i)\), \(i=1,\ldots,N\), where \(t_i\in\mathcal{I}\), some interval
  • Solution to SIR is \((t,x(t))\) for \(t\in\mathcal{I}\)
  • Suppose parameters of the model are \(p\)
  • We want to minimise the error function \[ E(p) = \sum_{i=1}^N \|x(t_i)-y_i\| \]
  • Norm is typically Euclidean, but could be different depending on objectives
  • So given a point \(p\) in (admissible) parameter space, we compute the solution to the ODE, compute \(E(p)\)
  • Using some minimisation algorithm, we seek a minimum of \(E(p)\) by varying \(p\)

What are \(y_i\) and \(x(t_i)\) here?

  • In epi data for infectious diseases, we typically have incidence, i.e., number of new cases per unit time
  • In SIR model, this is \(\beta SI\) or \(\beta SI/N\), so, if using mass action incidence and Euclidean norm \[ E(p)=\sum_{i=1}^N(\beta S(t_i)I(t_i)-y_i)^2 \] or, if using standard incidence \[ E(p)=\sum_{i=1}^N \left(\beta \frac{S(t_i)I(t_i)}{N}-y_i\right)^2 \]

Implementing in practice

See the code practicum_01_fitting.R, which we will go over now