calculation of the linear regression equation

조회 수: 1 (최근 30일)
som
som 2011년 12월 28일
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
Walter Roberson
Walter Roberson 2011년 12월 30일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Matt Tearle
Matt Tearle 2011년 12월 28일
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.)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by