Advanced Octave A52 — Parameter estimation from an ODE model

by Giux GX-TXT, octave-en, scripts-en 2 min read

Advanced GNU Octave with GX-TXT · Module 09

A dynamic model becomes more useful when we compare its predictions with observations. We design two parameters of a synthetic decay and check the forecast with an ODE solutor.

Objectives and prerequisites

We use the callback and nonlinear_fit of Module 06, along with ode45 of A49. The test uses GX-TXT dev112-P011-bis and GNU Octave 9.4.0. Import stima_ode.m, register it and run it in the Runner. The Dataset octave_advanced_ode_fit is created-only: to repeat, use a new session or change the ID.

From model to parameters

The model is dy/dt = -k*y, with initial condition y(0) = A. The analytical solution is A*exp(-k*t). We create 11 synthetic observations from a model with A = 2 and k = 0.6 s⁻¹, adding a small deterministic disturbance. They are not experimental measures.

We register a callback for analytical solution and pass it to NUMERIC_API_v1/nonlinear_fit with [1.8, 0.4] initial values. unwind_protect ensures the callback is released. Once estimated A and K, ode45 integrates the same equation and the program compares the numerical result with the analytical solution using those parameters. The ODE forecast is published as Dataset.

In the test the estimate converges with A≈ 2.002807 and k ≈ 0.600515 s⁻¹; the RMS of the residuals is about 0.010557. The maximum difference between integration and analytical formula is about 6.75 × 10⁻¹¹. This control checks the consistency of the two solutions for the estimated parameters; it does not show that a model correctly describes real data.

Identification and noise

Numerical convergence is not enough to establish that the parameters are well identified. Few times, too short interval or noise can make similar the predictions of different combinations of parameters. Examine residues, uncertainties, initial conditions and sensitivity; if the model has no analytical solution, the objective function may require numerical integration, with costs and tolerances to be controlled.

Exercise

  1. What parameters are estimated?
  2. What compares control with ode45?
  3. Convergence ensures that a real experiment identifies parameters well?

Worked solution

  1. The initial amplitude A and the decay rate k.
  2. Numerical integration with the analytical solution calculated at the same parameters and times.
  3. No. We need information data and noise, model, and identifiability checks.

Download the Module 09 scripts (ZIP)

#GNU Octave #GX-TXT #GX-TXT public APIs

Other steps of this project

Leave a Reply

Your email address will not be published. Required fields are marked *