using lsqcurvefit with normalized error

5 ビュー (過去 30 日間)
minu pilvankar
minu pilvankar 2019 年 9 月 11 日
コメント済み: minu pilvankar 2019 年 9 月 11 日
Hello,
I am using lsqcurvefit to fit a data set . However, the data points (ydata) I have has a very wide range (10^-3 to 10^3). So, when the lsqcurvefit tries to minimize the squared error, it minimizes it for the initialdata points (of higher values of ydata) and then gives a bad fit as we move ahead (to lower values of ydata). I tried using fmincon instead of lsqcurvefit and wrote a function (similar to lsqcurevfit) to minimize the error. But I modified this function by normalizing each error with the data point so that each data point gets similar weightage (be of higher or lower magnitude). This way I get a good fit but then I cannot plot the 95% confidence interval. So i am going back to lsqcurvefit. Is there a way to use lsqcurvefit that can normalize the error at each data point and give better fit? or can I plot the 95% confidence interval with fmincon?

採用された回答

Matt J
Matt J 2019 年 9 月 11 日
編集済み: Matt J 2019 年 9 月 11 日
This way I get a good fit but then I cannot plot the 95% confidence interval.
fmincon doesn't return the Jacobian, but it does return the Hessian, which you can use in a similar way to compute confidence intervals.
Is there a way to use lsqcurvefit that can normalize the error at each data point and give better fit?
Yes, if F(x,xdata) is your model function, then call lsqcurvefit as,
lsqcurvefit(@(x,xdata) F(x,xdata)./ydata, x0, xdata, ones(size(ydata)) );
  1 件のコメント
minu pilvankar
minu pilvankar 2019 年 9 月 11 日
Thank you Matt!! This was really helpful!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by