How to compute R-squared value
조회 수: 30 (최근 30일)
이전 댓글 표시
Hi,
I have the below matrix, and I want to compute correlation coeficient and R2(R-squared value), I used "corrcoef" function to get correlation coefficients, but I dont any find any function like this to compute R2.Can any one help me how to compute R2.
my example: A=rand(10,10) [R,P,RLO,RUP]=corrcoef(A).
Many thanks in advance.
댓글 수: 0
답변 (1개)
Star Strider
2016년 6월 24일
Computing R-squared for a regression is straightforward.
댓글 수: 6
Star Strider
2016년 6월 25일
You are doing a simple correlation, not a regression, so the correlation coefficient using the corrcoef function is appropriate for your data:
A = [0.1622 0.6020 0.4505 0.8258 0.1067
0.7943 0.2630 0.0838 0.5383 0.9619
0.3112 0.6541 0.2290 0.9961 0.0046
0.5285 0.6892 0.9133 0.0782 0.7749
0.1656 0.7482 0.1524 0.4427 0.8173];
[R,P,RLO,RUP]=corrcoef(A);
Note that while ‘P’, ‘RLO’, and ‘RUP’ are calculated correctly, from a statistical perspective, the main diagonals of all of them should be 0, not 1.
If you have the Statistics and Machine Learning Toolbox, you can also use the corr function. Since I do not know the details of what you are doing, you will have to choose the appropriate function.
The results I get from corr are exactly the same that corrcoef returns.
If you want to do a regression on your data, develop a model for it and post it back here. From it we can calculate an R-squared value. The R-suqared statistic is used as one measure to assess the ‘goodness-of-fit’ of a regression model to the data.
참고 항목
카테고리
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!