Correlation coefficient for robust fit and regress fitting are they equal?
조회 수: 10 (최근 30일)
이전 댓글 표시
I have done regression analysis for the x and Y using two cases. For the first regression I used 'regress' and for the second case 'robustfit'. How can I get the correlation coefficient of the two? shouldn't they be different? here is the script I tried to work upon..
figure (1)
[a,b]= robustfit(x,y);
plot(x,a(1)+a(2).*x,'g');
figure (2)
[a1, b1]=regress(y, [ones(size(x)) x]) ;
plot(x,a1(1)+a1(2).* x,'r','LineWidth',2);
Thanks for your help
댓글 수: 0
채택된 답변
the cyclist
2013년 2월 10일
If your data don't have any outliers, then the results of a robust regression will be very similar to a plain linear regression.
For example, here is some code comparing the two:
x = rand(20,1);
y = x + 0.3*rand(20,1);
y(1) = 40;
figure
hold on
[a,b]= robustfit(x,y);
plot(x,a(1)+a(2).*x,'g');
[a1, b1]=regress(y, [ones(size(x)) x]) ;
plot(x,a1(1)+a1(2).* x,'r','LineWidth',2);
Notice that I deliberately added an outlier [y(1)= 40], and plotted the lines on the same plot to compare. If you comment out that line y(1) = 40, then those lines will be (nearly) on top of each other.
In the latter case, you may need to use
>> format long
to see that a and a1 are actually a little different from each other.
댓글 수: 4
the cyclist
2013년 2월 10일
As stated in the documentation, the stats output of the commands
>> [b,bint,r,rint,stats] = regress(...)
and
>> [b,stats] = robustfit(...)
will give a list of lots of statistics. I'm truly not sure what you mean by "correlation coefficients", which is usually something measured between two data variables, not something from a fit. Maybe you mean R^2, which is sometimes referred to as the coefficient of determination? I know that is reported for the regress() command, but not sure for robustfit().
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Descriptive Statistics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!