# 数据变换（统计学）

统计学中的数据变换是指施加于数据或随机变量上的一个函数，最常见的目的在于稳定方差、线性化关系、使效应可加，或使偏态分布更为对称并近似正态。1964年提出的Box–Cox幂变换仅假定：在对数据作某种适当变换之后，正态、同方差、线性的模型是适用的，而对变换本身的推断则通过似然函数和后验分布进行<sup>[1](https://rss.onlinelibrary.wiley.com/doi/10.1111/j.2517-6161.1964.tb00553.x)</sup>。

| 关键事实 | 细节 |
|---|---|
| Box–Cox族 | 当\( \lambda \neq 0 \)时为\( y^{(\lambda)} = (y^{\lambda} - 1)/\lambda \)，当\( \lambda = 0 \)时为\( \log y \)；\( \lambda = 1 \)表示不作变换，\( \lambda = 1/2 \)为平方根，\( \lambda = -1 \)为倒数<sup>[2](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)</sup> |
| 定义域 | Box–Cox要求数据严格为正；Yeo–Johnson（2000）将其推广到正值和负值<sup>[3](https://link.springer.com/article/10.1007/s10994-026-06994-3)</sup><sup> • </sup><sup>[4](https://sklearn.org/stable/modules/generated/sklearn.preprocessing.PowerTransformer.html)</sup> |
| 方差稳定化 | 要求\( \mathrm{var}\{g(Y)\} \approx V(\mu)\{g'(\mu)\}^2 \)为常数，可得\( g(t) = \int 1/\sqrt{V(u)}\, du \)；Poisson计数用平方根，二项比例用arcsin(√Y)<sup>[5](https://link.springer.com/chapter/10.1007/978-3-031-88365-1_6)</sup><sup> • </sup><sup>[6](https://www2.stat.duke.edu/courses/Fall18/sta721/lectures/Boxcox/boxcox.pdf)</sup> |
| 反变换偏差 | 对于对数正态数据\( (\mu, \sigma^2) \)，原始均值为\( \exp(\mu + \sigma^2/2) \)，因此对对数尺度均值取指数得到的是\( \exp(\mu) \)，会低估；Duan的涂抹估计量可对此加以校正<sup>[7](https://pmc.ncbi.nlm.nih.gov/articles/PMC4120293/)</sup><sup> • </sup><sup>[8](https://casrai.org/guides/log-and-other-data-transformations)</sup> |
| 使用频率 | 在一项针对使用回归类模型检验假设的研究的调查中，66%至少使用了一种变换，其中对数变换最为常见<sup>[9](https://journals.sagepub.com/doi/10.1177/1094428121991907)</sup> |

## 数学基础

Box–Cox变换对正的\( y \)定义为

\[ y^{(\lambda)} = \begin{cases} \dfrac{y^{\lambda} - 1}{\lambda}, & \lambda \neq 0 \\ \log y, & \lambda = 0 \end{cases} \]

对数情形由洛必达法则在\( \lambda \to 0 \)时得到，这消除了普通幂变换在\( \lambda = 0 \)处会出现的不连续性<sup>[5](https://link.springer.com/chapter/10.1007/978-3-031-88365-1_6)</sup>。由于变换改变了数据的尺度，在变换后的尺度上拟合正态模型需要在似然中引入雅可比校正\( \log J = (\lambda - 1)\sum \log y_i \)<sup>[2](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)</sup>。该变换的归一化版本具有一个有用的性质：\( \lambda \)与回归系数\( \beta \)之间近似正交，因此\( \beta \)的估计几乎不受\( \lambda \)取值的影响<sup>[5](https://link.springer.com/chapter/10.1007/978-3-031-88365-1_6)</sup>。

**方差稳定化。** 若\( Y \)的均值为\( \mu \)、方差为\( V(\mu) \)，则使方差近似为常数的变换\( g \)满足\( \mathrm{var}\{g(Y)\} \approx V(\mu)\{g'(\mu)\}^2 \)，从而给出

\[ g(t) = \int \frac{1}{\sqrt{V(u)}}\, du. \]

对于Poisson计数，这给出平方根变换；对于二项比例，则给出\( \arcsin(\sqrt{Y}) \)<sup>[5](https://link.springer.com/chapter/10.1007/978-3-031-88365-1_6)</sup><sup> • </sup><sup>[6](https://www2.stat.duke.edu/courses/Fall18/sta721/lectures/Boxcox/boxcox.pdf)</sup>。最能实现正态性的变换未必等同于方差稳定化变换<sup>[6](https://www2.stat.duke.edu/courses/Fall18/sta721/lectures/Boxcox/boxcox.pdf)</sup>。

## 常见变换及其用途

**对数。** 用于压缩严格为正且右偏、变异性大致随量级一同增大的数据——收入、药物浓度和人口计数是典型例子<sup>[8](https://casrai.org/guides/log-and-other-data-transformations)</sup>。对数或倒数变换要求没有零值；平方根即使存在零值也仍然适用<sup>[10](https://journals.sagepub.com/doi/10.1177/00045632211050531)</sup>。

**平方根与倒数。** 平方根比对数温和，适合类Poisson的计数数据；倒数更强，但会颠倒数值的顺序<sup>[8](https://casrai.org/guides/log-and-other-data-transformations)</sup>。

**Box–Cox与Yeo–Johnson。** Box–Cox要求数据严格为正；Yeo–Johnson可处理正值或负值观测，且只依赖一个幂参数。数据分析表明，允许正响应和负响应采用不同幂次的扩展Yeo–Johnson是必要的，而非参数平滑则是更为灵活的替代方案<sup>[2](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)</sup><sup> • </sup><sup>[4](https://sklearn.org/stable/modules/generated/sklearn.preprocessing.PowerTransformer.html)</sup>。软件实现通过最大似然估计\( \lambda \)；SciPy的`boxcox`基于对轮廓对数似然应用截断值\( \tfrac{1}{2}\chi^2(1-\alpha, 1) \)来返回\( \lambda \)的置信区间<sup>[11](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.boxcox.html)</sup>。

**零值与负值。** 对于偶尔含有零值或负值的数据，可在幂变换之前加上一个常数\( \alpha \)（常取二分之一或一）来应用Box–Cox<sup>[12](https://grodri.github.io/glms/notes/c2s10)</sup>。广泛使用的log(x+1)变通做法并非中性：所加常数是任意的，会不成比例地扭曲小值，而且不同常数可能实质性改变估计的效应量。反双曲正弦（asinh）变换在大值上几乎与对数表现相同，但在零点和负值处有定义<sup>[8](https://casrai.org/guides/log-and-other-data-transformations)</sup>。

**秩与分位数方法。** 非参数分位数变换在有数千个样本时可以把任意分布强制变为高斯分布，但它较难解释，且在少于几百个点的数据集上容易过拟合，此时推荐使用幂变换<sup>[13](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_map_data_to_normal.html)</sup>。

## 选择与拟合变换

NIST将Box–Cox族视为一种探索性工具，用于使非正态数据近似正态<sup>[14](https://www.itl.nist.gov/div898/handbook/eda/section3/boxcox.htm)</sup>。在回归中，变换追求两个目标：误差方差的齐性和拟合的线性化，而这两者可能相互冲突；NIST建议首先尝试平方根、自然对数和倒数变换以均化方差<sup>[15](https://www.itl.nist.gov/div898/handbook/pmd/section6/pmd624.htm)</sup>。

**λ的敏感性。** 在NIST的一个例子中，最优Box–Cox \( \lambda \)为−0.1，但−0.2到0.2之间的任何取值都给出相当类似的结果，因此为便于解释而选择了更简单的自然对数变换<sup>[15](https://www.itl.nist.gov/div898/handbook/pmd/section6/pmd624.htm)</sup>。

**离群值。** \( \lambda \)的最大似然估计及相关的似然比检验可能受离群值严重影响，已有稳健估计程序被提出<sup>[16](https://encyclopediaofmath.org/wiki/Box-Cox_transformation)</sup>。前向搜索及其扇形图提供了一种数据排序，用于评估所选变换的稳健性<sup>[2](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)</sup>。

**响应变量与预测变量。** 变换可施加于响应变量、预测变量或两者，且会改变所估计的函数形式。一项在八种情景下的模拟研究发现，当真实的剂量–反应关系为线性时，对自变量作对数变换会使效应估计产生偏差，且在预测变量的较低百分位数处平均偏差更大；即使存在离群值，未变换预测变量的模型覆盖率也接近95%，且估计偏差最小。该研究建议，是否对预测变量作对数变换应基于赤池信息准则等模型拟合统计量，而非预测变量的偏度<sup>[17](https://pmc.ncbi.nlm.nih.gov/articles/PMC9574910/)</sup>。在多元回归中，不同预测变量可能需要不同的变换，而可解释性会受损：即使拟合相似，解释每英里加仑数也比解释每加仑英里数的对数更容易<sup>[18](https://www.lexjansen.com/nesug/nesug05/an/an7.pdf)</sup>。

## 反变换与解释

**对数正态偏差。** 若\( y_i \)服从对数正态分布\( (\mu, \sigma^2) \)，则\( E(y_i) = \exp(\mu + \sigma^2/2) \)。对数变换后数据的均值估计的是\( \mu \)，因此对其取指数得到\( \exp(\mu) \)，这低估了原始尺度上的均值<sup>[7](https://pmc.ncbi.nlm.nih.gov/articles/PMC4120293/)</sup>。更一般地，由于Jensen不等式，对对数尺度上的预测均值取指数所恢复的更接近几何均值而非算术均值；Duan的涂抹估计量（1983）是针对这种反变换偏差的一种校正<sup>[8](https://casrai.org/guides/log-and-other-data-transformations)</sup><sup> • </sup><sup>[9](https://journals.sagepub.com/doi/10.1177/1094428121991907)</sup>。

**对数尺度上的系数。** 在对数线性模型中，系数\( b \)意味着预测变量每增加一个单位，结果变量相应变化\( (e^b - 1) \times 100\% \)，这一近似在\( b \)较大时失效；在对数–对数模型中，系数即为弹性<sup>[8](https://casrai.org/guides/log-and-other-data-transformations)</sup>。参考区间可通过变换至正态性、在变换尺度上计算区间再反变换得到；在一个实例中，log10白蛋白给出男性参考区间1.2–62.2 μg/mL、女性参考区间1.2–92.2 μg/mL，并对对数尺度分布偏离正态处的上限提出了疑问<sup>[10](https://journals.sagepub.com/doi/10.1177/00045632211050531)</sup>。

## 数据一览

- 在调查的使用回归类模型检验假设的研究中，66%至少使用了一种变换；对数变换（手动使用或作为GLM的连接函数）最为常见，其次是logit/probit变换和幂变换<sup>[9](https://journals.sagepub.com/doi/10.1177/1094428121991907)</sup>。
- 对数正态均值偏差因子为\( \exp(\sigma^2/2) \)：当对数尺度上\( \sigma = 1 \)时，反变换后的均值约为真实均值的\( 1/e^{0.5} \approx 1/1.65 \)<sup>[7](https://pmc.ncbi.nlm.nih.gov/articles/PMC4120293/)</sup>。
- 在NIST的例子中，Box–Cox似然在最优值−0.1附近的\( \lambda = -0.2 \)到0.2之间近乎平坦，因此更倾向于对数变换<sup>[15](https://www.itl.nist.gov/div898/handbook/pmd/section6/pmd624.htm)</sup>。
- 在二十五种变量分布类型上，两步变换在偏度（56%的变量类型）、峰度（100%）和内容效度（100%）方面优于金融与会计研究中常用的变换<sup>[19](https://link.springer.com/article/10.1007/s11156-025-01412-6)</sup>。

## 与替代方法的比较

**GLM。** 随着为计数和比例设计的广义线性模型日益流行，平方根和反正弦等方差稳定化变换已不再流行，转而推荐Poisson回归和logistic回归<sup>[12](https://grodri.github.io/glms/notes/c2s10)</sup>。2025年的一篇文章推荐GLM作为变换非正态神经科学数据的替代方案，因为GLM允许研究者指定潜在的误差分布<sup>[20](https://www.eneuro.org/content/13/1/ENEURO.0414-25.2025)</sup>。对于医疗支出等零膨胀的非负结果，模拟证据表明，在GLM类估计量与ln(y)的最小二乘估计量之间作选择可能具有重大影响，偏度、峰度和异方差性会对某些估计量造成可观的偏差或精度损失<sup>[21](https://ideas.repec.org/p/nbr/nberte/0246.html)</sup>。

**稳健与无分布方法。** 使用M估计量的稳健回归可以在存在离群值和显著偏度的情况下给出有效的关联，但研究生方法学课程中很少讲授<sup>[20](https://www.eneuro.org/content/13/1/ENEURO.0414-25.2025)</sup>。Feng及其同事建议，在大多数情况下研究者应放弃对偏态数据的传统对数变换，改用广义估计方程等无分布方法<sup>[7](https://pmc.ncbi.nlm.nih.gov/articles/PMC4120293/)</sup>。对于包括零在内的非负结果因变量，一个团队建议使用未变换的因变量，如两部分模型或未变换的线性回归<sup>[22](https://onlinelibrary.wiley.com/doi/10.1111/obes.12583)</sup>。

**一场仍在进行的分歧。** 这些建议与较早的标准做法相冲突。NIST和应用指南将对数、平方根和倒数变换视为均化方差和改善拟合的一线工具<sup>[15](https://www.itl.nist.gov/div898/handbook/pmd/section6/pmd624.htm)</sup>，而上述模拟和计量经济学文献则认为变换往往无益，且可能使估计产生偏差。另一个分歧在于非正态性究竟有多重要：2026年的一篇会议论文认为，相对于其实际后果，回归中对正态性的担忧常被夸大，因此分位数回归或缩尾处理等补救措施往往并无必要<sup>[23](https://journals.aom.org/doi/10.5465/AMPROC.2026.123bp)</sup>，而2025年的金融学比较则发现变换的选择会实质性影响偏度、峰度和内容效度<sup>[19](https://link.springer.com/article/10.1007/s11156-025-01412-6)</sup>。

## 陷阱

**不保证正态性。** 施加幂变换并不保证变换后的特征服从正态分布；取决于位置、尺度以及离群值的存在，幂变换可能降低正态性，导致假设正态性的ANOVA或机器学习方法产生错误结果<sup>[3](https://link.springer.com/article/10.1007/s10994-026-06994-3)</sup>。对对数正态、卡方、Weibull、高斯和均匀数据应用Box–Cox和Yeo–Johnson的实例表明，这些变换对某些分布有效，对另一些则失效<sup>[13](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_map_data_to_normal.html)</sup>。

**变异性可能增加。** 与常见看法相反，无论是否存在离群值，对数变换往往可能增加而非减少变异性，在某些情况下还会使分布比原始数据更偏<sup>[7](https://pmc.ncbi.nlm.nih.gov/articles/PMC4120293/)</sup>。变换的目标是得到合理对称的分布，而非精确的正态性<sup>[10](https://journals.sagepub.com/doi/10.1177/00045632211050531)</sup>。

**函数形式，而非分布。** 变换应由关系的函数形式而非变量的边际分布来驱动，因为变换改变的是所估计的效应类型；变量的非正态性本身并不是问题，尽管非正态的因变量可能暗示存在非线性过程<sup>[9](https://journals.sagepub.com/doi/10.1177/1094428121991907)</sup>。

**数值问题。** 较大的负或正\( \lambda \)值可能在后续计算中导致数值问题，这对机器学习工作流中的自动变换是一个隐患<sup>[3](https://link.springer.com/article/10.1007/s10994-026-06994-3)</sup>。

## 近期进展

近期一些应用文章推荐将GLM、两部分模型、稳健M估计量或GEE作为对偏态或零膨胀结果进行常规变换的替代方案<sup>[20](https://www.eneuro.org/content/13/1/ENEURO.0414-25.2025)</sup><sup> • </sup><sup>[22](https://onlinelibrary.wiley.com/doi/10.1111/obes.12583)</sup><sup> • </sup><sup>[7](https://pmc.ncbi.nlm.nih.gov/articles/PMC4120293/)</sup>。在金融与会计研究中，两步变换已被提出并经过基准测试，在二十五种分布类型上优于现有的主要变换<sup>[19](https://link.springer.com/article/10.1007/s11156-025-01412-6)</sup>。在机器学习实践中，scikit-learn的PowerTransformer对Box–Cox或Yeo–Johnson通过最大似然估计\( \lambda \)，但同一文献也警告变换可能使正态性变差，且极端的\( \lambda \)值会导致数值问题<sup>[4](https://sklearn.org/stable/modules/generated/sklearn.preprocessing.PowerTransformer.html)</sup><sup> • </sup><sup>[3](https://link.springer.com/article/10.1007/s10994-026-06994-3)</sup>。asinh变换在零点和负值处有定义，正日益被用作零值安全的类对数替代方案<sup>[8](https://casrai.org/guides/log-and-other-data-transformations)</sup>，而基于分位数的归一化仅在样本量充足时才被推荐，因为在小数据集上存在过拟合风险<sup>[13](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_map_data_to_normal.html)</sup>。

## References

1. [Box, G. E. P., & Cox, D. R. (1964). An Analysis of Transformations. Journal of the Royal Statistical Society B.](https://rss.onlinelibrary.wiley.com/doi/10.1111/j.2517-6161.1964.tb00553.x)
2. [Atkinson, A., Riani, M., & Corbellini, A. (2021). The Box-Cox Transformation: Review and Extensions. Statistical Science 36(2).](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)
3. [Location and Scale-Invariant Power Transformations for Transforming Data to Normality. Machine Learning (2026).](https://link.springer.com/article/10.1007/s10994-026-06994-3)
4. [scikit-learn: PowerTransformer](https://sklearn.org/stable/modules/generated/sklearn.preprocessing.PowerTransformer.html)
5. [Transformations. Springer reference-work chapter.](https://link.springer.com/chapter/10.1007/978-3-031-88365-1_6)
6. [Clyde, M. Transformations and Normality. Duke STA 721 lecture notes.](https://www2.stat.duke.edu/courses/Fall18/sta721/lectures/Boxcox/boxcox.pdf)
7. [Feng, C. et al. (2014). Log-transformation and its implications for data analysis.](https://pmc.ncbi.nlm.nih.gov/articles/PMC4120293/)
8. [Log and Other Data Transformations: When to Use Them and What They Cost. CASRAI guide.](https://casrai.org/guides/log-and-other-data-transformations)
9. [Eight Simple Guidelines for Improved Understanding of Transformations and Nonlinear Effects. Organizational Research Methods.](https://journals.sagepub.com/doi/10.1177/1094428121991907)
10. [Best practice in statistics: The use of log transformation. Annals of Clinical Biochemistry (2021).](https://journals.sagepub.com/doi/10.1177/00045632211050531)
11. [SciPy Manual: scipy.stats.boxcox](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.boxcox.html)
12. [Statistics and Population: variance-stabilizing transformations and Box-Cox](https://grodri.github.io/glms/notes/c2s10)
13. [scikit-learn example: Map data to a normal distribution](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_map_data_to_normal.html)
14. [NIST/SEMATECH e-Handbook: Box-Cox Normality Plot](https://www.itl.nist.gov/div898/handbook/eda/section3/boxcox.htm)
15. [NIST/SEMATECH e-Handbook: Transformations to Improve Fit and Equalize Variances](https://www.itl.nist.gov/div898/handbook/pmd/section6/pmd624.htm)
16. [Encyclopedia of Mathematics: Box-Cox transformation](https://encyclopediaofmath.org/wiki/Box-Cox_transformation)
17. [Log-transformation of independent variables: must we? (2022)](https://pmc.ncbi.nlm.nih.gov/articles/PMC9574910/)
18. [Transforming Variables for Normality and Linearity. NESUG 2005.](https://www.lexjansen.com/nesug/nesug05/an/an7.pdf)
19. [Understanding non-normality in business, finance, and accounting research. Review of Quantitative Finance and Accounting (2025).](https://link.springer.com/article/10.1007/s11156-025-01412-6)
20. [Most Neuroscience Data Is Not Normally Distributed. eNeuro (2025).](https://www.eneuro.org/content/13/1/ENEURO.0414-25.2025)
21. [Estimating Log Models: To Transform or Not to Transform? NBER Working Paper.](https://ideas.repec.org/p/nbr/nberte/0246.html)
22. [Why Transform Y? The Pitfalls of Transformed Regressions with a Mass at Zero. Oxford Bulletin of Economics and Statistics.](https://onlinelibrary.wiley.com/doi/10.1111/obes.12583)
23. [Why Non-Normality is (Usually) not Your Regression Problem. Academy of Management Proceedings (2026).](https://journals.aom.org/doi/10.5465/AMPROC.2026.123bp)

---
*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 › Algebra and transformations of random variables › Functions of random variables

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/data-transformation-statistics

English original: https://www.edgepedia.org/data-transformation-statistics
