What's the difference between R^2 and r?
4 ビュー (過去 30 日間)
古いコメントを表示
Hello, can someone explain please, what's exactly the meaning of R_squared? The one which is defined in the link below - r_squared
and R(1,2) is you can get if you do:
R = corrcoef(A,B);
A,B - 2 vectors.
1 件のコメント
Rik
2017 年 12 月 27 日
This doesn't look like a Matlab question to me. Have you read the doc for corrcoef?
回答 (1 件)
ANKUR KUMAR
2017 年 12 月 27 日
The value which you get for corrcoef (gives output a matrix and further extracting second column from first row) or from corr2 (if you have specified tool box) is the correlation coefficient. The same answer you can get manually too by doing this calculation.
function [ P ] = pcorr( a,b )
%pcorr gives the Pearson Correlation Coefficient between the two vector of
%equal dimensions
if length(a)~=length(b)
error('Dimension of both must be equal')
end
n=(numel(a)*nansum(a.*b))-(nansum(a)*nansum(b));
d1=(numel(a)*nansum(a.^2))-((nansum(a))^2);
d2=(numel(b)*nansum(b.^2))-((nansum(b))^2);
P=n/(sqrt(d1*d2));
end
The above value can be positive or negative.
Squared R (R^2) is just the square of r.
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!