This app illustrates the method of boostrapping data, which is one way one can obtain confidence intervals for parameters when fitting mechanistic models to data.
The data and the underlying simulation model are the same as in the ‘Basic model fitting’ app. If you haven’t worked your way through that app, do that first.
This app allows you to fit the parameters either in linear or log space. Fitting in log space can be useful if you have a large range of parameters you want to try. The underlying problem is the same, no matter what scale you fit your parameters on, but sometimes one version or the other can lead to better performance of your solver.
Note that while choosing to fit parameters on a linear or log scale is just done to optimize performance of the computer code, a decision to fit your data on a linear or log scale corresponds to different biological problems and underlying assumptions about the processes that generated the data and any uncertainty/noise. For this app, data is fit on a log scale.
The main new feature of this app is the inclusion of bootstrapping, a sampling process that allows one to obtain confidence intervals for the estimated parameters. The basic approach goes like this:
Bootstrapping is conceptually easy to understand and also fairly easy to implement. The big drawback is that it takes time to run. Instead of fitting your model (until it converges) once, you now have to do it many times. That can take time and usually requires a mix of fast computers, parallelization, good/quick optimizers and simple models. For our teaching model, we’ll use a simple model, only few bootstrap samples and a limited number of interations per fit.
The fit is run multiple times. First, the model is fit to the actual data. Then, the model is fit again for the specified number of bootstrap samples to data created by the bootstrap sampling process. Note that the default for the number of fitting iterations and the number of bootstrap samples are both very low. Usually, we might want to take as many steps as it takes until we found the best fit (which could be a lot). And we generally also want 100s or 1000s of bootstrap samples. Unfortunately, that would take very long, so for the purposes of this teaching app, we’ll keep both iterations and bootstrap samples at values less than you should use in a ‘real world’ situation.
Note that the time it takes to run the code scales with the product of the iterations and number of bootstraps, so if you set both high, things will get really slow.
simulate_fitconfint.R
. See its help file for information on how to call and use it directly.boot
package, which does the sampling and repeatedly calls the nloptr
solver, which in turn runs the underlying simulation model simulate_basicvirus.R
.Efron, Bradley, and Robert Tibshirani. 1993. An introduction to the bootstrap. New York: Chapman & Hall.