Multivariate Regression Parameter Optimization

조회 수: 4 (최근 30일)
Andrew
Andrew 2012년 7월 3일
I am trying to find the values that will optimize parameters in an equation. Two measured values are related by an equation to equal a known value.
The equation is: y=a*(x^b)*(z^c)
x & z = measured values (vectors of length n)
a,b & c = the unknown free parameters (single values)
I also have known values Y that y should approximately equal. Therefore, I want to find the set of parameters a,b&c that minimizes the difference between Y and y (given all measured values).
What is the best way to do this in MATLAB?
Thanks!
-Andrew

채택된 답변

Teja Muppirala
Teja Muppirala 2012년 7월 3일
NLINFIT is good.
NonLinearModel.fit is also good.
But since your problem involves fitting a surface with only two independent variables, it can be done very simply using the Curve Fitting Toolbox functions.
You can do it interactively using CFTOOL and then generate the MATLAB code automatically (recommended), or if you want to write the code out by hand yourself, you can do something along these lines:
x = rand(100,1);
z = rand(100,1);
atrue = 2.5;
btrue = 1.7;
ctrue = 1.2;
Y = atrue*(x.^btrue).*(z.^ctrue) + 0.05*randn(size(x)) ;
scatter3(x,z,Y);
hold all;
F = fittype('a*x^b*z^c','Independent',{'x' 'z'});
M = fit([x z],Y,F) % Or specify an initial guess: M = fit([x z],Y,F,'Start',[0 0 0])
plot(M)
  댓글 수: 1
Andrew
Andrew 2012년 7월 3일
I ended up using this approach - thanks so much! Worked perfectly.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

the cyclist
the cyclist 2012년 7월 3일
I think that the function nlinfit() from the Statistics Toolbox will do what you want.
  댓글 수: 1
Andrew
Andrew 2012년 7월 3일
편집: the cyclist 2012년 7월 3일
This worked too, but I ended up implementing Teja's approach. Thank you for your fast response!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by