Effacer les filtres
Effacer les filtres

calculation of the linear regression equation

2 vues (au cours des 30 derniers jours)
som
som le 28 Déc 2011
Hi all
I have two arrays of data including A , B. I want to calculate the linear regression equation of A , B as well as the value of Sum of Square Errors (SSE).
How can I write this program in Matlab.
Thanks in advance.
  1 commentaire
Walter Roberson
Walter Roberson le 30 Déc 2011
Somayeh, it would be appreciated if you would use more meaningful tags instead of your initials. You can find your own threads by using the My Questions link; tags are for categorizing questions.

Connectez-vous pour commenter.

Réponse acceptée

Matt Tearle
Matt Tearle le 28 Déc 2011
If you have Statistics Toolbox
doc regress
If not, you can do it yourself (although you'll have to take care of NaNs or other glitches).
F = [ones(size(A)),A];
c = F\B
will give you the coefficients. Then
Bmodel = F*c;
resid = B - Bmodel;
SSE = resid' * resid
(Assuming everything is a column vector.)

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by