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 次查看(过去 30 天)
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 个评论
Torsten
Torsten 2018-11-9
编辑:Torsten 2018-11-9
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)

请先登录,再进行评论。

采纳的回答

Torsten
Torsten 2018-11-9
编辑:Torsten 2018-11-9
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 个评论
helen flountzi
helen flountzi 2018-11-13
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 2018-11-13
编辑:Torsten 2018-11-13
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.

请先登录,再进行评论。

更多回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by