calculation of the linear regression equation
1 次查看(过去 30 天)
显示 更早的评论
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
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
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!