How to obtain R square value

조회 수: 196 (최근 30일)
Andoni Mendialdua
Andoni Mendialdua 2014년 9월 1일
댓글: Star Strider 2014년 9월 1일
Hi all,
coefficientsold = polyfit(AAT,QErot1,1)
Ygg=polyval(coefficientsold,AAT)
figure
axis([-10 80 0 15])
plot(AAT,QErot1,'s',AAT,Ygg,'--','MarkerFaceColor',[0 0 0])
By using this code what I obtain is a linear equation that fits my data, but I am not able to obtain the R-square value.
I would be glad if you could tell be how to obtain the r-square value, if it is possible by the use of the regress function, because I am not able to understand the use of this function properly.
Thank you very much
Andoni

채택된 답변

Star Strider
Star Strider 2014년 9월 1일
Use the core MATLAB corrcoef function. It will give you the R values and the significance levels (probabilities) and confidence intervals if you want them.
  댓글 수: 6
Andoni Mendialdua
Andoni Mendialdua 2014년 9월 1일
Thank you, and what about the R matrix? what does 0.938 value mean?
Andoni
Star Strider
Star Strider 2014년 9월 1일
My pleasure!
The 0.938 value is the correlation coefficient for your data. I refer you to the documentation (hyperlink in my original Answer) for a full explanation. (The 1 values on the diagonal of the R matrix are because each variable is perfectly correlated with itself. This is correct, even though the corresponding P values equal to 1 on the diagonal of the P matrix are not correct.)

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

추가 답변 (1개)

Kalpesh Patil
Kalpesh Patil 2014년 9월 1일
correlation_coeff = corr2(Ygg,AAT);
r_sqr = power(correlation_coeff,2);
  댓글 수: 4
Iain
Iain 2014년 9월 1일
Why do you think that an R-squared value of 1 is wrong?
Are you actually asking for an RMS?
Andoni Mendialdua
Andoni Mendialdua 2014년 9월 1일
r-square is wrong because with the new equation I obtain, the results are not the same as my initial datas. Thank you,
Andoni

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

Community Treasure Hunt

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

Start Hunting!

Translated by