Correlation coefficient for robust fit and regress fitting are they equal?

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

 Accepted Answer

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 Comments

Yes , I agree with you. My question really is how can I display these coefficients in my graph for both cases. I want this for comparison purpose
Can you be very specific about what coefficients you want? If you type
>> doc robustfit
and
>> doc regress
you can get an exhaustive list of all the output, which includes just about everything about the fit.
You could then use the text() command to display the values on your graph.
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().

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!