Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/notebooks/insulin.ipynb
Views: 531
Modeling and Simulation in Python
Insulin minimal model
Copyright 2017 Allen Downey
Data
We have data from Pacini and Bergman (1986), "MINMOD: a computer program to calculate insulin sensitivity and pancreatic responsivity from the frequently sampled intravenous glucose tolerance test", Computer Methods and Programs in Biomedicine, 23: 113-122..
The insulin minimal model
In addition to the glucose minimal mode, Pacini and Bergman present an insulin minimal model, in which the concentration of insulin, , is governed by this differential equation:
Exercise: Write a version of make_system
that takes the parameters of this model, I0
, k
, gamma
, and G_T
as parameters, along with a DataFrame
containing the measurements, and returns a System
object suitable for use with run_simulation
or run_odeint
.
Use it to make a System
object with the following parameters:
Exercise: Write a slope function that takes state, t, system as parameters and returns the derivative of I
with respect to time. Test your function with the initial condition .
Exercise: Run run_ode_solver
with your System
object and slope function, and plot the results, along with the measured insulin levels.
Exercise: Write an error function that takes a sequence of parameters as an argument, along with the DataFrame
containing the measurements. It should make a System
object with the given parameters, run it, and compute the difference between the results of the simulation and the measured values. Test your error function by calling it with the parameters from the previous exercise.
Hint: As we did in a previous exercise, you might want to drop the errors for times prior to t=8
.
Exercise: Use leastsq
to find the parameters that best fit the data. Make a System
object with those parameters, run it, and plot the results along with the measurements.
Exercise: Using the best parameters, estimate the sensitivity to glucose of the first and second phase pancreatic responsivity:
For , use the best estimate from the glucose model, 290. For and , use the inital measurements from the data.