Determine the the slope and its uncertainty?

36 visualizaciones (últimos 30 días)
Lizan
Lizan el 16 de Nov. de 2012
Comentada: Ankan Biswas el 28 de En. de 2018
Hi,
I am trying to linearly fit a set of data points, find the slope and then compute the uncertainty of the slope, +, - uncertainty. How can I do this in MATLAB?
I have tried to look into regression and regress but are getting very confused.
Additional questions:
What is the outputs of Regress? Does it gives the slope of the linear fit? And the 95% confidence intervals? I noticed that b not the same as the polyfit?
Likewise, the polyfit does not give the same slope as regression. And Regression gives me matrix of result.. shouldn't slope just be one value. The inputs are just vectors of x,y data.
Thanks

Respuesta aceptada

Jos (10584)
Jos (10584) el 16 de Nov. de 2012
Do you also want to fit an offset? Polyfit does that for you, but you have to tell regress explicitly,. Example:
x = 1:10 ; y = 10*x+3 ;
yr = y + rand(size(y))-0.5 ; % add noise
[b, bint] = regress(yr(:), [x(:) ones(numel(x),1)])
  2 comentarios
Lizan
Lizan el 18 de Nov. de 2012
What does regress give you? Does it give you,
slope + error; slope - error;
I also find that polyfit does not give the same slope as in regress. Its confusing for me...
Venkatessh
Venkatessh el 14 de Mzo. de 2013
Editada: Venkatessh el 14 de Mzo. de 2013
regress gives you the 95% confidence interval of the coefficients (slope and y-intercept). I am not sure if you can get the errors by simply subtracting the confidence interval and even if you can bear in mind that it gives you a 95% estimate (~ 2-sigma) and not a 1-sigma uncertainty.
I am assuming by error you mean the uncertainty

Iniciar sesión para comentar.

Más respuestas (1)

Ganessen Moothooveeren
Ganessen Moothooveeren el 14 de Mzo. de 2013
But still how to find the uncertainty in the slope using the polyfit function??
  2 comentarios
Venkatessh
Venkatessh el 14 de Mzo. de 2013
In order to estimate the uncertainties of the coefficients obtained from polyfit function, you may follow the following steps:
[b, bint] = polyfit(x,y,1);
b_err = sqrt(diag((bint.R)\inv(bint.R'))./bint.normr.^2./bint.df);
where, b_err contains the uncertainty of the coefficients
Ankan Biswas
Ankan Biswas el 28 de En. de 2018
Hi Venkatessh, Can you explain the rationale behind your error calculation? Thanks in advance.

Iniciar sesión para comentar.

Categorías

Más información sobre Support Vector Machine Regression en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by