nonlinear regression

1 visualización (últimos 30 días)
john birt
john birt el 20 de Feb. de 2011
Comentada: Mohamad Mossad el 12 de Nov. de 2018
After spending five hours reading how to use matlab for nonlinear regression I am so confused. I'm sure there must be some simple way to use a Non linear regression.
I have a function
y = m*x+d*g+d*(g^(1/k)+b^2+(b-x)^2)^k
where Im trying to find parameters m,d,g,k,b with 0<k<1
I have (x,y) data such as
(0.01, 0.00000020369272)
(0.02, 0.00000040738543)
(0.03, 0.00000061107815)
etc...
Is there some simple way to use Matlab to find the parameters?

Respuesta aceptada

Matt Tearle
Matt Tearle el 21 de Feb. de 2011
If you have Statistics Toolbox, you can use nlinfit, although there's no guarantee that k will be in the interval (0,1). Make a function handle to your function:
f = @(c,x) c(1)*x+c(2)*c(3)+c(2)*(c(3)^(1/c(4))+c(5)^2+(c(5)-x).^2).^c(4);
f is a function of the parameters ( c ) and x. Make an initial guess of the parameters:
c = rand(5,1);
Then call nlinfit with the data you have:
cfit = nlinfit(xdata,ydata,f,c)
If you don't have Stats TB, you can brute-force it in MATLAB by making an error function to minimize. Define f as above. Then define
g = @(c) norm(f(c,xdata)-ydata);
Now use fminsearch to find the coefficients, starting with an initial guess (as before)
cfit = fminsearch(g,c)
If you have Optimization Toolbox, you can use fmincon to constrain k.
  4 comentarios
Ho Nam Ernest Yim
Ho Nam Ernest Yim el 4 de Abr. de 2018
Editada: Ho Nam Ernest Yim el 4 de Abr. de 2018
Can I know are there any other methods I can use also to compare the performances among methods. I used nlinfit and lsqcurvefit, I looked up and found fitnlm and lsqnonlin are same as the about methods. And I have looked into different methods such as ridge , robust , polyfit but none of them fit the case that lsqcurvefit is considering : as in lsqcurvefit(fun,x0,xdata,ydata) *nonlinear case Please help me =( , I have been looking at it for a while
Mohamad Mossad
Mohamad Mossad el 12 de Nov. de 2018
Can I ask how to initialize the parameters in a better way, so that it doesn't change with every run because random numbers don't really solve the problem?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Linear and Nonlinear Regression 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