nonlinear regression
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
john birt
il 20 Feb 2011
Commentato: Mohamad Mossad
il 12 Nov 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?
0 Commenti
Risposta accettata
Matt Tearle
il 21 Feb 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 Commenti
Ho Nam Ernest Yim
il 4 Apr 2018
Modificato: Ho Nam Ernest Yim
il 4 Apr 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
il 12 Nov 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?
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Linear and Nonlinear Regression in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!