Obtaining uncertainty in parameters fitting discrete data points with component data, using "\" or "mldivide"

I'm not too familiar with the statistics behind least-square fitting, but please bear with me.
I would like to fit a data set ("Result") with linear combinations of component data sets ("a", "b"). I'm currently using the "\" command, which is equivalent to mldivide:
x =[a;b]'\Result'
A linear combination of the red and yellow curve creates the blue curve that fits the blue curve.
For example, a result would be:
x =
0.9796
0.2119
However, is there any way I can obtain uncertainty/error from doing this? Thanks.

 采纳的回答

The statistics and Machine Learning Toolbox regress (link) function can also do this.
For your problem, it would be:
[b,bint] = regress(Result', [a;b]');
with ‘b’ the estimated parameters, and ‘bint’ their confidence intervals.
The documentation says that the F-statistic and p-value (in the stats output if you ask for it) may not be accurate without an intercept term, so ignore them.

更多回答(1 个)

curvefit() is the only related call that returns r-squared directly. https://www.mathworks.com/help/curvefit/fit.html#outputarg_gof

2 个评论

To clarify, I'm asking if I can obtain uncertainties for the calculatd values. From my understanding, the curve-fitting toolbox fits analytical functions and not user-obtained discrete values.
%create some input data.
%replace this section with reading in your a, b, and c
t = linspace(0,1,50);
a = exp(-(t-1/2).^2);
b = tan(t);
x1 = randn(); x2 = randn();
c = a*x1 + b*x2; %x1 and x2 will need to be recovered
%create the fitting type
ft = fittype('a*x1+b*x2', 'coeff', {'x1','x2'}, 'indep', {'a','b'});
%guess an initial solution to keep it quiet
x0 = [.5 .5]
%do the fitting
[x, gof] = fit( [a(:), b(:)], c(:), ft, 'StartPoint', x0 )
%how good was it?
gof.rsquare

请先登录,再进行评论。

类别

帮助中心File 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