nonlinear regression
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Matt Tearle
2011 年 2 月 21 日
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 件のコメント
Ho Nam Ernest Yim
2018 年 4 月 4 日
編集済み: Ho Nam Ernest Yim
2018 年 4 月 4 日
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
2018 年 11 月 12 日
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?
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Linear and Nonlinear Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!