Correlation coefficient calculator (Pearson and Spearman)

Correlation coefficient calculator: Pearson's r or Spearman's rank correlation for paired data, with r², a t statistic and a two-sided p-value.

업데이트 검증한 예제: 4

Hours studied (default example).
Exam score for the same students, in the same order.
시도하기
Correlation coefficient
Correlation coefficient: 0.981638
최대 소수 자릿수: 6; 가장 가까운 값, 중간값은 0에서 먼 쪽으로
Strength
Strong positive
Coefficient of determination r²
0.963613
t statistic
14.555426
Degrees of freedom
8
p-value (two-sided)
4.865 × 10⁻⁷
Pairs n
10

r = 0.9816 is a strong positive linear association; r² = 0.9636, so a straight line accounts for 96.36% of the variation in y. p = 4.86 × 10⁻⁷: if there were no correlation in the population, a sample of 10 pairs would show one at least this strong with that probability. Correlation alone does not show that one variable causes the other.

y against x

6070802468xy
PairsLeast-squares line
계산 방법 S
  1. Means

    xˉ=4.3,yˉ=66.8\bar x = 4.3,\quad \bar y = 66.8
  2. Sums of squares and cross-products

    Sxx=48.1,Syy=993.6,Sxy=214.6S_{xx} = 48.1,\quad S_{yy} = 993.6,\quad S_{xy} = 214.6
  3. 상관관계

    r=SxySxxSyy=214.648.1×993.6=0.981638r = \frac{S_{xy}}{\sqrt{S_{xx}S_{yy}}} = \frac{214.6}{\sqrt{48.1 \times 993.6}} = 0.981638
  4. Test statistic

    t=rn−21−r2=0.98163881−0.963613=14.555426t = r\sqrt{\frac{n-2}{1-r^2}} = 0.981638\sqrt{\frac{8}{1-0.963613}} = 14.555426
  5. Two-sided p-value

    p=2 P(T8>∣t∣)=4.86464×10−7p = 2\,P(T_{8} > |t|) = 4.86464 \times 10^{-7}

    Assumes the pairs are independent and roughly bivariate normal.

Correlation coefficient calculator (Pearson and Spearman) 소개

Pearson's r measures how closely paired values follow a straight line: r = Sxy/√(Sxx·Syy), the sum of cross-products of deviations from the two means divided by the square root of the product of the two sums of squares. It runs from −1, a perfect falling line, through 0 to +1, a perfect rising line. Spearman's ρ is Pearson's r computed on the ranks, so it measures any steadily rising or falling trend and is less affected by outliers. The p-value comes from t = r√((n − 2)/(1 − r²)) with n − 2 degrees of freedom.

The default pairs hours studied with exam scores for 10 students: r = 0.9816, r² = 0.9636 and p = 4.9 × 10⁻⁷, a strong positive association.

A correlation near 0 rules out only a straight-line relationship: y = x² for x from −3 to 3 has r = 0 exactly.

계산 예제

Hours studied vs score (default)

x values
1, 2, 2, 3, 4, 5, 5, 6, 7, 8
y values
52, 55, 61, 58, 66, 70, 68, 75, 79, 84
Coefficient
Pearson r
Correlation coefficient
0.981638
Coefficient of determination r²
0.963613
t statistic
14.555426
Degrees of freedom
8
p-value (two-sided)
4.865 × 10⁻⁷
Strength
Strong positive

검증 출처: Python fractions for Sxx, Syy, Sxy with a decimal square root; p from the closed-form Student t CDF for integer df (Abramowitz & Stegun 26.7.4)

Negative association

x values
10, 20, 30, 40, 50, 60
y values
8.1, 7.4, 7.9, 6.2, 5.8, 6.0
Coefficient
Pearson r
Correlation coefficient
-0.891042
t statistic
-3.925982
p-value (two-sided)
0.017161
Strength
Strong negative

검증 출처: Python fractions with decimal square roots; p = 2·(1 − F_t(|t|; 4)) from the A&S 26.7.4 closed form

Spearman with tied ranks

x values
1, 2, 2, 3, 4, 5, 5, 6
y values
3, 1, 4, 4, 5, 9, 2, 6
Coefficient
Spearman ρ
Correlation coefficient
0.575768
t statistic
1.724946
p-value (two-sided)
0.135297
Degrees of freedom
6
Strength
Strong positive

검증 출처: Python: ties averaged by hand (x ranks 1, 2.5, 2.5, 4, 5, 6.5, 6.5, 8), Pearson r of the ranks with fractions (Sxy = 95/4, Sxx = 41, Syy = 83/2), p from the A&S 26.7.4 t CDF

Perfect straight line

x values
1, 2, 3, 4
y values
3, 5, 7, 9
Coefficient
Pearson r
Correlation coefficient
1
Coefficient of determination r²
1
p-value (two-sided)
0
Strength
Strong positive

검증 출처: y = 2x + 1 exactly, so r = 1 by definition and no sample could be more extreme

자주 묻는 질문

What does a correlation coefficient of 0.7 mean?

A fairly strong positive linear association: as x rises, y tends to rise, and r² = 0.49 says a straight line accounts for 49% of the variation in y. Cohen (1988) called r = 0.1 small, 0.3 medium and 0.5 large, and the Strength output uses those cut-offs. They are rough conventions from the behavioural sciences, so what counts as strong still depends on the field.

What is the difference between Pearson and Spearman correlation?

Pearson's r measures linear association using the values themselves; Spearman's ρ applies the same formula to their ranks, so it measures any monotonic trend. For y = x³ with x from 1 to 10, Spearman gives exactly 1 but Pearson gives 0.928. Spearman also resists outliers and suits ordinal data such as ratings, while Pearson's r is the one that matches a least-squares line.

Does correlation imply causation?

No. A correlation shows that two variables move together, not why. A third variable can drive both, as hot weather raises both ice-cream sales and drownings. The cause can also run the other way, or the pattern can be chance: test 20 unrelated pairs at α = 0.05 and about one will look significant. Showing cause takes a randomized experiment or a careful causal design.

How do you test whether a correlation is significant?

Convert r to t = r√((n − 2)/(1 − r²)) and compare it with a t distribution with n − 2 degrees of freedom. The default data give r = 0.9816 with n = 10, so t = 14.56 on 8 df and p = 4.9 × 10⁻⁷. Significance depends heavily on n: with 1,000 pairs, r = 0.07 already gives p = 0.027, although it explains under 0.5% of the variation.

“Correlation coefficient calculator (Pearson and Spearman)”의 정확도는 어느 정도인가요?

정확도는 입력값과 계산 방법의 가정에 따라 달라집니다. 십진 연산은 유효숫자 50자리를 사용하지만, 추정값·수치해석 방법·원본 데이터의 정밀도는 더 낮을 수 있습니다. 표시값을 반올림해도 이러한 한계는 사라지지 않습니다. 독립적인 출처의 풀이와 대조한 계산 예시: 4. 예를 들어 “Hours studied vs score (default)”은 Python fractions for Sxx, Syy, Sxy with a decimal square root; p from the closed-form Student t CDF for integer df (Abramowitz & Stegun 26.7.4)와 대조해 확인합니다.

이 계산 방법의 출처는 무엇인가요?

NIST/SEMATECH e-Handbook of Statistical Methods, §7.1.3 / Dataplot CORRELATION (Pearson and rank correlation); Spearman (1904), The proof and measurement of association between two things, American Journal of Psychology 15; Cohen (1988), Statistical Power Analysis for the Behavioral Sciences, 2nd ed., §3.2 (r = 0.1, 0.3, 0.5).

이 계산기 소개

r=∑(xi−xˉ)(yi−yˉ)∑(xi−xˉ)2∑(yi−yˉ)2,t=rn−21−r2r = \frac{\sum (x_i-\bar x)(y_i-\bar y)}{\sqrt{\sum (x_i-\bar x)^2 \sum (y_i-\bar y)^2}},\qquad t = r\sqrt{\frac{n-2}{1-r^2}}

출처

  1. NIST/SEMATECH e-Handbook of Statistical Methods, §7.1.3 / Dataplot CORRELATION (Pearson and rank correlation)
  2. Spearman (1904), The proof and measurement of association between two things, American Journal of Psychology 15
  3. Cohen (1988), Statistical Power Analysis for the Behavioral Sciences, 2nd ed., §3.2 (r = 0.1, 0.3, 0.5)

출처와 대조하여 검증

이 계산기에는 독립적인 출처에서 답을 얻은 계산 예제가 4개 있습니다. 테스트 모음에서 실행되며 여기에서도 실행할 수 있습니다.

관련 계산기