How can I use levenberg-marquardt algorithm with two variables

5 views (last 30 days)
Hello, everyone.
I started to use lsqcurvefit function in matlab for estimating the parameters in reaction kinetics.
My reaction kinetics are like this => r = k1[a][b] / (1+k2[a]+k3[b])^2
When I tried to use lsqcurvefit function, it demands only one variable x, however in my kinetics there are two variables a and b for output(reaction rate r).
Is there any way that can estimate reaction constant parameters k1,k2,k3 with two reaction variables a and b in kinetics?
I searched in matlab to solve this problem, but I couldn't find it.
I hope I could get good reply at here.
Thanks!
  4 Comments
J. Alex Lee
J. Alex Lee on 29 Mar 2021
As @Star Strider's answer shows, I guess no, it is not important for you to know what the "residual function" is, because lsqcurvefit will automagically define it for you based on the model function that you give it. But it is definitely necessary for estimation since it is what defines "how far is your model from your data at this current set of estimates".
As for estimation and validation samples, I don't know if that's a typical thing for these types of goals, but if you're not going to use all available data I suppose I'd throw another caution out there to make sure you sample well...depending on how noisy your data is, 8 data points for 3 parameters doesn't seem like a lot, but i guess also depends on how "rigid" the model is...
Taeksang Yoon
Taeksang Yoon on 30 Mar 2021
Oh, I see.
I agree with your opinion. I think I need more experimental data, or modify my model with other assumptions.
Thanks for the reply!

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 29 Mar 2021
It will be necessary to parameterize the ‘k’ constants (that you want to estimate) as:
k1 = p(1)
k2 = p(2)
k3 = p(3)
If the independent variable data are ‘a’ and ‘b’ and the dependent variable is ‘r’, then the data will be:
x = [a(:) b(:)];
y = r(:);
the objective function will be:
kinfcn = @(b,x) p(1).*x(:,1}.*x(:,2) ./ (1 + p(2).*x(:,1) + p(3).*x(:,2)).^2;
and the lsqcurvefit call would then be:
B = lsqcurvefit(kinfcn, rand(3,1), x, y, zeros(1,3))
The ‘zeros(1,3)’ prevents the kinetic constants (the ‘k’ parameters from being negative, since if I remember correctly, they should always be greater than 0.
  5 Comments
Taeksang Yoon
Taeksang Yoon on 31 Mar 2021
Oh, I got it.
Thanks for the corrected code and the result!
I also get the estimation result by using curve fitting toolbox, and it also shows the almost same result.
Star Strider
Star Strider on 31 Mar 2021
As always, my pleasure!
I do not have the Curve Fitting Toolbox, since I can do everything I need to do with the Statistics and Machine Learning Toolbox and the Optimization Toolbox and Global Optimization Toolbox.

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!