Pearson's correlation coefficient when applied to a population is commonly represented by the Greek letter ρ (rho) and may be referred to as the population correlation coefficient or the population Pearson correlation coefficient. The formula for ρ is:
where, is the covariance,
is the standard deviation of
,
is the mean of
, and
is the expectation.
Alternative formulae for the sample Pearson correlation coefficient are also available:
The above formula suggests a convenient single-pass algorithm for calculating sample correlations, but, depending on the numbers involved, it can sometimes benumerically unstable.
Spearman's rank correlation coefficient
For a sample of size n, the n raw scores are converted to ranks
, and ρ is computed from:
where , is the difference between ranks
示例[編輯]
在此例中,我們要使用下表所給出的原始數據計算一個人的 智商和其每周花在 電視上的小時數的相關性。
智商, ![]() |
每周花在電視上的小時數, ![]() |
106 | 7 |
86 | 0 |
100 | 27 |
101 | 50 |
99 | 28 |
103 | 29 |
97 | 20 |
113 | 12 |
112 | 6 |
110 | 17 |
首先,我們必須根據以下步驟計算出 ,如下表所示。
- 排列第一列數據 (
)。 創建新列
並賦以等級值 1,2,3,...n。
- 然后,排列第二列數據 (
). 創建第四列
並相似地賦以等級值 1,2,3,...n。
- 創建第五列
保存兩個等級列的差值 (
和
).
- 創建最后一列
保存
的平方.
智商, ![]() |
每周花在電視上的小時數, ![]() |
等級 ![]() |
等級 ![]() |
![]() |
![]() |
86 | 0 | 1 | 1 | 0 | 0 |
97 | 20 | 2 | 6 | −4 | 16 |
99 | 28 | 3 | 8 | −5 | 25 |
100 | 27 | 4 | 7 | −3 | 9 |
101 | 50 | 5 | 10 | −5 | 25 |
103 | 29 | 6 | 9 | −3 | 9 |
106 | 7 | 7 | 3 | 4 | 16 |
110 | 17 | 8 | 5 | 3 | 9 |
112 | 6 | 9 | 2 | 7 | 49 |
113 | 12 | 10 | 4 | 6 | 36 |
根據 計算
。 樣本容量n為 10。 將這些值帶入方程
得 ρ = −0.175757575...
