Borrar filtros
Borrar filtros

Parameter fitting problem: I use lsqnonlin to fit 3 parameters into a system of ODES and everything works fine until I inserted a Confidence Interval as one of my coefficients.At that point the fitted parameter vector took only the initial guess

1 visualización (últimos 30 días)
Parameter fitting problem: I use lsqnonlin to fit 3 parameters into a system of ODES and everything works fine until I inserted a Confidence Interval as one of my coefficients.At that point the fitted parameter vector took only the initial guess
  2 comentarios
Torsten
Torsten el 9 de Nov. de 2018
Editada: Torsten el 9 de Nov. de 2018
Commented by Helen Flountzi:
For example, this is one of my ODEs: dy(1)=h*(1-z)*N-lamda0*nsp_r*y(1)-(m+q)*y(1)+param2*y(4); if I replace z with z=0.289+(0.615-0.289)*rand; my fitting process provides as solution the initial param2(0)that I gave initially(I already tried to change the initial values &still the same)

Iniciar sesión para comentar.

Respuesta aceptada

Torsten
Torsten el 9 de Nov. de 2018
Editada: Torsten el 9 de Nov. de 2018
Each time your ODE function is called, "rand" takes a different value between 0 and 1. This makes it impossible for the ODE solver to get a solution of your ODE and for the fitting tool to determine optimal parameters. So it gives up and returns the initial guesses.
Call the fitting tool for different, but fixed values for z in a loop and see how the optimal parameters change.
Best wishes
Torsten.
  4 comentarios
helen flountzi
helen flountzi el 13 de Nov. de 2018
The problem is that I have a main script, which calls one function and this function calls another function, which contains the ODEs that I m trying to solve and z is one of the coefficients and it needs to be replaced there after it's random selection in order to be evaluated from lsqnonlin!I wrote the code you suggested it in my script, but now it gives the message "Undefined function or variable 'z_actual', which means that somehow z_actual is not replaced in the equations...any idea for this?
Torsten
Torsten el 13 de Nov. de 2018
Editada: Torsten el 13 de Nov. de 2018
Somewhere in your code you have to call "lsqnonlin". That's where you have to insert the above loop. This way, z_actual is passed to the function "fun_lsqnonlin" of lsqnonlin. In this function, you somehow have to call an ODE integrator (e.g. ODE45). Pass z_actual a second time to the function "fun_ODE_integrator" where you define your ODE in the same way as you did for lsqnonlin. Then you can use z_actual as coefficient in your ODE function.
Or, although usually not recommended: Define z_actual as global and insert
global z_actual
in the function where you call lsqnonlin and in the function where you supply the ODE.

Iniciar sesión para comentar.

Más respuestas (1)

george hargenrader
george hargenrader el 11 de Nov. de 2020
How does inserting a range of starting values for one parameter equate to a confidence interval? What information do you gain by doing this?

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by