Advanced Octave A52 — Parameter estimation from an ODE model
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
- What parameters are estimated?
- What compares control with
ode45? - Convergence ensures that a real experiment identifies parameters well?
Worked solution
- The initial amplitude A and the decay rate k.
- Numerical integration with the analytical solution calculated at the same parameters and times.
- No. We need information data and noise, model, and identifiability checks.
Other steps of this project
- Advanced Octave A75 — Dynamical systems in phase space
- Advanced Octave A81 — Geography of the waves and a 3D surface
- Advanced Octave A82 — Age, sex and demographic inequalities
- Advanced Octave A83 — All-cause mortality, certified COVID deaths and surveillance
- Advanced Octave A84 — A reproducible public account
- Advanced Octave A73 — Optimization landscapes and 3D trajectories