Calibrating a Model Against Data (Model Fitting)
In this example, we have a model with parameters C1, k1, k2 and k3 that we want to calibrate to get an optimum fit of our model to a set of data stored in a Time Series Element.
Description
For each data point, a residual (i.e. data minus model value) is calculated and squared using a Discrete Change Element. The Discrete Change Element triggers at each time point where there is data (in this example at t = 1, 2, 5, 10, 15, 24, 32 and 48 days). Squared residuals calculated by the Discrete Change Element are summed by an Integrator Element to calculated a sum of the squared residuals. This is the objective function that we want to minimize in the optimization by modifying values of C1, k1, k2 and k3. The 'model' in this case is a simple 3-exponential function, but any model of arbitrary complexity could be used in place of this function.
Download the model file
Screen Captures of the Model
Results are shown in the image below. The top plot shows the model time history and data before the model has been calibrated. The bottom plot shows the fitted model (after optimization). Parameters before optimization were C1 = 20, k1 = 2 day, k2 = 6 day, k3 = 15 day. Parameter values after optimization are: C1 = 15.3, k1 = 1.08 day, k2 = 5.00 day, k3 = 16.3 day.