필터 지우기
필터 지우기

How to calculate R-square using robust linear regression function

조회 수: 2 (최근 30일)
jalcaraz
jalcaraz 2012년 11월 29일
답변: Christian 2015년 5월 19일
In the linear regression function (regress), one may get the R^2 value directly from one of the 'stats' variable in [b, bint, r, rint, stats] = regress(y,X) function
I want to do a robust linear regression with [b,stats] = robustfit(X,Y)
However, I can't find in the help panel how to assess R^2 from the output variables of the 'robustfit' function.
Any help will be very welcome
JA

답변 (2개)

Matt Fig
Matt Fig 2012년 11월 29일
[brob, rob_stats] = robustfit(x,y);
rsquare = corr(y,brob(1)+brob(2)*x)^2

Christian
Christian 2015년 5월 19일
Hi there, although this thread is really old, I'm gonna give it a shot :-) I encountered the same problem and Matt's formula seems to solve it beautifully when regressing against only 1 independent variable. However, my x contains 4 factors. How would you go about calculating R-squared in that case? I tried the following, but it doesn't seem to work:
B_Rsqrd(1,j) = corr(Y,b(1)+b(2)*X(:,1)+b(3)*X(:,2)+b(4)*X(:,3)+b(5)*X(:,4))^2;
Can someone help me out here?
Any help is much appreciated!
Christian

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by