# 相关系数

相关系数是一个介于−1与+1之间的单一数值，用于衡量两个变量的成对取值沿一条直线排列的紧密程度。最广为人知的版本是皮尔逊积矩相关系数（Pearson's product-moment correlation coefficient），总体记为ρ，样本记为r，它估计的是两个变量之间线性关联的强度<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup>。取值+1对应完全的线性正相关，−1对应完全的线性负相关，0则对应无线性关系<sup>[2](https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/correlat.htm)</sup>。

| 关键事实 | 详情 |
|---|---|
| 定义 | 两个变量之间线性关系的度量，计算式为 \( r = \frac{S_{xy}}{\sqrt{S_{xx}} \sqrt{S_{yy}}} \)，其中 \( S_{xy} = \sum_{i=1}^{N}(X_i-\bar{X})(Y_i-\bar{Y}) \)<sup>[2](https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/correlat.htm)</sup> |
| 取值范围与单位 | 从−1到+1，无量纲；其取值不受测量单位的影响，但受测量误差的影响<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup> |
| r²的解释 | 将r平方得到决定系数，即一个变量的方差中可由另一个变量解释的比例；r = ±1意味着100%被解释<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup> |
| 显著性检验 | 检验r = 0时使用 \( \mathrm{VAL} = \left| \frac{(N-2) r^2}{1 - r^2} \right| \)，对照自由度为1和N − 2的F分布<sup>[2](https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/correlat.htm)</sup> |
| 置信区间 | 费希尔正态近似基于 \( Z = \mathrm{atanh}(r) = \tfrac{1}{2}\log\frac{1+r}{1-r} \)，为r提供置信限<sup>[3](https://itl.nist.gov/div898/software/dataplot/refman1/auxillar/corrconf.htm)</sup> |
| 非参数替代方法 | 斯皮尔曼等级相关用秩次替换原始取值，因而对离群值稳健<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup> |
| 关键局限 | 相关不蕴含因果；一个混杂因素可以在两个并无直接因果联系的变量之间制造出高相关<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup> |

## 定义与计算

对于成对观测 \( (X_i, Y_i) \)，i = 1至N，皮尔逊系数是两个变量的协方差除以二者标准差之积。美国国家标准与技术研究院（NIST）的Dataplot参考手册通过平方和与交叉乘积来表达这一计算<sup>[2](https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/correlat.htm)</sup>：

\[ r = \frac{S_{xy}}{\sqrt{S_{xx}} \sqrt{S_{yy}}} \]

其中 \( S_{xx} = \sum (X_i - \bar{X})^2 \)，\( S_{yy} = \sum (Y_i - \bar{Y})^2 \)，\( S_{xy} = \sum (X_i - \bar{X})(Y_i - \bar{Y}) \)。两个变量必须具有相同数量的元素<sup>[4](https://www.itl.nist.gov/div898/software/dataplot/refman2/ch2/correlat.pdf)</sup>。由于平方和带有各变量的单位，该比值为一无单位的纯数<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup>。

该系数衡量一条直线对数据散点图的拟合程度<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup>。它并非穿过各观测点的最佳拟合直线的度量，而只是观测点落在一条直线上的程度的度量；一对明显相关但呈曲线（非线性）关联的变量仍可能给出较低的r，不过非线性关联并不总是返回0，例如指数关系的r = 0.5<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup>。

## 解释

**已解释方差。** 将系数平方得到R²，即一个变量的统计变异中可由另一个变量解释的比例。相关系数为−1或+1时，每个变量都可由另一个变量无误差地确定，此时决定系数为1，意味着100%的变异被解释<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup>。

**回归斜率。** |r|等于标准化变量的两条回归直线斜率的几何平均数；当X与Y的标准差相等时，两个回归系数与相关系数在数值和符号上完全一致<sup>[5](https://jse.amstat.org/v5n3/falk.html)</sup>。

**经验法则。** 不应使用固定的文字标签（小、中等、大）来描述相关强度；解释应取决于分析的背景和目的<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup>。

## 统计推断

样本值r不随样本量变化，但无相关检验的P值会随样本量变化<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup>。Dataplot记录了通过自由度为1和N − 2的F累积分布对r = 0的检验，使用 \( \mathrm{VAL} = \left| \frac{(N-2) r^2}{1 - r^2} \right| \)<sup>[2](https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/correlat.htm)</sup>。

对于区间估计，费希尔正态近似通过反双曲正切变换r，\( Z = \mathrm{atanh}(r) \)，再用双曲正切将置信限变换回来；Dataplot输出50%至99.9%置信水平的区间<sup>[3](https://itl.nist.gov/div898/software/dataplot/refman1/auxillar/corrconf.htm)</sup>。

皮尔逊系数可以在没有任何分布假设的情况下计算，尽管双变量正态性是一些统计推断形式的基础，而该系数相当稳健，在偏态分布中仍可能被有效估计<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup><sup> • </sup><sup>[15](https://doi.org/10.1213/ANE.0000000000002864)</sup>。

## 陷阱与局限

**范围限制。** 该系数对观测值的范围敏感。在一个包含50个观测值的假想数据集中，r = 0.87；仅分析最低的25个观测值时，r = 0.57<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup>。由于范围影响取值，相关系数难以在组间或研究间直接比较，研究者也可能通过纳入额外的低值和高值来抬高系数<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup>。

**离群值。** 离群值可能大幅抬高或压低相关系数，因此在依赖皮尔逊r之前应检查数据集中是否存在离群值<sup>[6](https://online.stat.psu.edu/stat100/Lesson05)</sup>。当必须保留离群值时，斯皮尔曼等级相关是更为稳健的替代方法<sup>[7](https://pressbooks.uiowa.edu/data-analysis-in-the-psychological-sciences/chapter/unit-7-correlational-measures/)</sup>。

**因果。** 相关系数不能解释为因果关系。两个变量相关，可能是因为一个导致另一个，可能是因为二者共享某个潜在的共同原因，也可能只是巧合<sup>[8](https://www.amstat.org/docs/default-source/amstat-documents/modelingwithlogarithms.pdf)</sup>。在一个临床例子中，开具ACE抑制剂与肾功能下降相关，并非因为药物导致肾功能下降，而是因为二者都与白蛋白尿有关；多变量回归可以校正此类混杂<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup>。

**方法间的一致性。** 该系数常被错误地用于评估两种测量方法是否一致。一种方法若始终读出另一方法两倍的数值，仍会与它完全相关，因为只有完全的正线性或负线性关系才分别给出r = 1或r = -1，其他线性关联则不会<sup>[16](https://www.ncbi.nlm.nih.gov/books/NBK550206/)</sup>。若要评估可互换性，推荐的替代方法是组内相关系数（ICC）——科恩κ的推广，同时考虑相关性和系统偏倚——以及布兰德-奥特曼图（Bland–Altman plot）中显示的95%一致性界限<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup>。

**数据类型与结构。** 相关分析假设观测相互独立，当一个或两个变量以序数尺度测量时，不应使用皮尔逊系数，例如0–10的疼痛评分，其中相等的数值差异并不意味着潜在量的相等变化<sup>[9](https://pmc.ncbi.nlm.nih.gov/articles/PMC5079093/)</sup>。建议在计算r之前先绘制原始数据图，以检查非线性、离群值和异方差性<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup>。

## 变体

若干系数将相关的思想推广到其他数据类型。斯皮尔曼等级相关通过对观测值排秩，适用于序数数据或非正态分布<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup>。点二列相关将一个连续变量与一个二值变量联系起来，组内相关系数则评估多个观察者之间的一致性<sup>[11](https://docs.scipy.org/doc/scipy/reference/stats.html)</sup><sup> • </sup><sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)</sup>。相关也进入测量科学：在测量不确定度的评定中，量之间的相关性通过协方差技术和蒙特卡洛方法处理，包括保持相关矩阵半正定的算法<sup>[12](https://www.nist.gov/publications/correlation-uncertainty-measurement-discussion-state-art-techniques)</sup>。

## 历史

概念源头在于弗朗西斯·高尔顿（Francis Galton）的遗传研究。1875年，高尔顿将若干包甜豌豆种子分发给七位朋友，每包内种子重量一致但包与包之间不同；朋友们寄回收获的子代种子，高尔顿将子代种子重量对母代种子重量作图，发现中位数描绘出一条斜率小于1的正斜率直线，他记录下的第一个回归斜率为0.33<sup>[13](https://jse.amstat.org/v9n3/stanton.html)</sup>。高尔顿用“r”表示回归斜率；直到卡尔·皮尔逊（Karl Pearson）后来的处理，r才转而代表相关系数<sup>[13](https://jse.amstat.org/v9n3/stanton.html)</sup>。

皮尔逊于1896年在《伦敦皇家学会哲学学报》（*Philosophical Transactions of the Royal Society of London*）上发表了关于相关与回归的第一个严格的数学处理。在该文中，他将相关的最初数学公式归功于奥古斯特·布拉维（Auguste Bravais，1846），并指出布拉维偶然发现了积矩方法，却未能证明它给出数据的最佳拟合；皮尔逊补上了这一证明，表明任何偏离积矩的做法都会使由x预测y的效果变差<sup>[13](https://jse.amstat.org/v9n3/stanton.html)</sup>。早稻田大学的椎名健平（Kenpei Shiina）在2016年的一篇综述中追溯了这些起源以及布拉维、高尔顿、皮尔逊、炮兵科学家和斯皮尔曼的贡献，认为了解创造者最初的背景有助于研究者理解该系数的含义<sup>[14](https://www.jstage.jst.go.jp/article/sjpr/59/4/59_415/_article/-char/en)</sup>。

## References

1. [Janse RJ, Hoekstra T, Jager KJ. Conducting correlation analysis: important limitations and pitfalls. Nephrology Dialysis Transplantation (PMC).](https://pmc.ncbi.nlm.nih.gov/articles/PMC8572982/)
2. [CORRELATION (LET), Dataplot Reference Manual, NIST.](https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/correlat.htm)
3. [CORRELATION CONFIDENCE LIMITS, Dataplot Reference Manual, NIST.](https://itl.nist.gov/div898/software/dataplot/refman1/auxillar/corrconf.htm)
4. [Statistics LET Subcommands — CORRELATION, NIST.](https://www.itl.nist.gov/div898/software/dataplot/refman2/ch2/correlat.pdf)
5. [Falk R, Well AD. Many Faces of the Correlation Coefficient. Journal of Statistics Education 5(3), 1997.](https://jse.amstat.org/v5n3/falk.html)
6. [Relationships Between Measurement Variables, STAT 100, Penn State.](https://online.stat.psu.edu/stat100/Lesson05)
7. [Correlational Measures, Data Analysis in the Psychological Sciences, University of Iowa Pressbooks.](https://pressbooks.uiowa.edu/data-analysis-in-the-psychological-sciences/chapter/unit-7-correlational-measures/)
8. [Correlation and Cause and Effect, American Statistical Association (Data-Driven Mathematics series).](https://www.amstat.org/docs/default-source/amstat-documents/modelingwithlogarithms.pdf)
9. [Rahman S et al. Common pitfalls in statistical analysis: The use of correlation techniques. Perspect Clin Res (PMC).](https://pmc.ncbi.nlm.nih.gov/articles/PMC5079093/)
10. [scipy.stats.pearsonr, SciPy v1.18.0 Manual.](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.pearsonr.html)
11. [Statistical functions (scipy.stats), SciPy v1.18.0 Manual.](https://docs.scipy.org/doc/scipy/reference/stats.html)
12. [Kessel R, Kacker R. Correlation in Uncertainty of Measurement — A Discussion of State of the Art Techniques. XIX IMEKO World Congress 2009, NIST.](https://www.nist.gov/publications/correlation-uncertainty-measurement-discussion-state-art-techniques)
13. [Stanton JM. Galton, Pearson, and the Peas: A Brief History of Linear Regression for Statistics Instructors. Journal of Statistics Education 9(3), 2001.](https://jse.amstat.org/v9n3/stanton.html)
14. [Shiina K. Origin of the correlation coefficient and its multifaceted interpretation. Japanese Psychological Review 59(4): 415–444, 2016.](https://www.jstage.jst.go.jp/article/sjpr/59/4/59_415/_article/-char/en)
15. [Correlation Coefficients: Appropriate Use and... : Anesthesia & Analgesia](https://doi.org/10.1213/ANE.0000000000002864)
16. [ncbi.nlm.nih.gov](https://www.ncbi.nlm.nih.gov/books/NBK550206/)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Probability theory › Random variables › Exchangeability, independence, and Gaussian structure › Uncorrelatedness and covariance structure

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/correlation-coefficient

English original: https://www.edgepedia.org/correlation-coefficient
