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에 대해 자세히 알아보기

제품

질문:

2017년 7월 8일

답변:

2017년 7월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by