What's the difference between R^2 and r?

4 ビュー (過去 30 日間)
Mark Golberg
Mark Golberg 2017 年 12 月 26 日
回答済み: ANKUR KUMAR 2017 年 12 月 27 日
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
Rik 2017 年 12 月 27 日
This doesn't look like a Matlab question to me. Have you read the doc for corrcoef?

サインインしてコメントする。

回答 (1 件)

ANKUR KUMAR
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.

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by