Difference between spearmann correlation and fit command

조회 수: 2 (최근 30일)
Gena
Gena 2013년 10월 11일
댓글: Gena 2013년 10월 13일
Hello all,
I have some data that I want to analyze (EMG of muscles vs subjects' fatigue) in order to find the relation between two measurs.
At first, I used the 'corr' command to calculate the spearman correlation coefficient between the EMG and the fatigue for each subject. Afterwards, I used the 'fit' command to fit a linear model to my data.
To my surprise, in some cases (about 5% of the cases), the spearman correlation coefficient was positive, but the fitted linear model had a negative slope (or vice versa).
Shouldn't they have the same tendency? Or am I doing something wrong?
I'm attaching my matlab code, and excel file with some example data that shows the spoken discrepancy.
Thank you.

채택된 답변

Peter Perkins
Peter Perkins 2013년 10월 11일
You're (correctly) fitting a linear model with a slope and an intercept. The "model" that a correlation coefficient is equivalent to has no intercept. Look at your figure to see why one is positive and the other negative.
Hope this helps.
  댓글 수: 1
Gena
Gena 2013년 10월 13일
Thank you for your answer, but there is still something that I don't understand. When you are saying that "the model has no intercept" you mean that the model is y=a*x (passes through the origin), if I understand it correctly. But what about other cases (as in the attached file) where the model of the correlation coefficient doesn't pass through the origin (and has a negative value, so as the slope of the fitted line)? What is the difference (after all, in both cases I'm using the same command - "corr")?
Thank you.

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

추가 답변 (1개)

Wayne King
Wayne King 2013년 10월 11일
I would not put any faith in the correlation coefficient, the p-value is 0.9 and the reported rho is close to 0.
  댓글 수: 1
Gena
Gena 2013년 10월 11일
I agree, but that is not the issue. There are some other cases where the correlation is more significant, but the discrepancy still exists.
Thank you for the answer.

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

카테고리

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