# 对数变换

对数变换将变量的每个取值替换为其对数值，这是统计学中的一种预处理步骤，用于在分析前稳定方差、降低偏度，并将乘性关系转化为加性关系。当结果变量严格为正、随预测变量呈指数增长，且方差依赖于其均值时，适用该变换。<sup>[1](https://ealdrich.github.io/Teaching/Econ114/LectureNotes/transform.html)</sup> 该变换将乘性（百分比）差异转化为加性差异，这正是线性回归模型所假设的类型。<sup>[2](https://s040.gse.harvard.edu/unit7.html)</sup> 其使用存在争议：对自变量进行对数变换已成为事实上的标准做法，然而模拟证据表明，当真实剂量-反应关系为线性时，该变换可能使效应估计产生偏倚；此外，回归中的正态性假设适用于误差项，而非预测变量。<sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC9574910/)</sup> 一些作者认为对数变换具有特殊性，应经常优先于未变换的分析；<sup>[4](https://onlinelibrary.wiley.com/doi/10.1002/sim.4780140810)</sup> 另一些作者则得出结论，在大多数情况下它并不能使数据变异更小或更接近正态。<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC4120293/)</sup>

| 关键事实 | 详情 |
|---|---|
| 作用 | 将乘性（百分比）差异转化为适合线性模型的加性差异<sup>[2](https://s040.gse.harvard.edu/unit7.html)</sup> |
| 底数选择 | 以10为底的对数和自然对数仅相差一个常数因子，因此底数不影响统计检验，但会改变回归斜率和截距<sup>[6](http://biostathandbook.com/transformation.html)</sup> |
| 回变换偏倚 | 对于均值为 \( \mu \)、方差为 \( \sigma^2 \) 的对数正态数据，\( E(y)=\exp(\mu+\sigma^2/2) \)，因此对对数均值取指数会低估算术均值<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC4120293/)</sup> |
| 偏度 | 对数变换仅对近似对数正态的数据消除偏度；在一项模拟中，偏度从0.34上升至1.16<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC4120293/)</sup> |
| Box-Cox联系 | 对数是Box-Cox幂变换在 \( \lambda = 0 \) 处的特例<sup>[7](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)</sup> |
| 零值 | 对数在零及以下无定义；常见的变通方法是加一个常数（计数数据通常加0.5）<sup>[6](http://biostathandbook.com/transformation.html)</sup> |
| 现代替代方案 | 带拟似然的广义线性模型可处理零结果，且无论方差模式如何都具有一致性<sup>[8](https://pure.au.dk/ws/files/307837131/Villadsen_Wulff_BJM_2021_AM.pdf)</sup> |

## 工作原理

该变换是一种稳定方差的尺度变换。对方差与均值平方成比例的变量应用德尔塔方法，可得到一个方差近似恒定的变换后变量；对于变异系数为 \( \sigma \) 的伽马分布响应变量，稳定方差的变换为 \( \log(Y) \)，其近似矩为 \( E\{\log(Y)\} = \log(\mu) - \sigma^2/2 \)，\( \operatorname{var}\{\log(Y)\} = \sigma^2 \)。<sup>[7](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)</sup> 更一般地，常数方差 \( A \) 无需变换，方差 \( A \cdot \mu \)（泊松数据）需要平方根变换，方差 \( A \cdot \mu^{2} \) 需要倒数变换，方差 \( A \cdot \mu(1-\mu) \)（二项比例）需要 \( \arcsin\sqrt{Y} \) 变换。<sup>[9](http://www.stat.umn.edu/hawkins/5302/Nonlinear%20Transformations%20and%20Variance%20Stabilizing%20Transformations.pdf)</sup>

由于对数将乘积转化为和，对结果变量取对数意味着预测变量的加性差异与结果变量的乘性差异相关联；同时对预测变量和结果变量取对数则得到双对数（弹性）解释。<sup>[2](https://s040.gse.harvard.edu/unit7.html)</sup> 若原始数据服从对数正态分布，则变换后的数据为正态分布，偏度被真正消除；否则该变换可能不会降低偏度，甚至可能使其增大。<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC4120293/)</sup>

## 操作步骤

1. 确认结果变量严格为正；\( \log x \) 在 \( x \le 0 \) 时无定义。<sup>[2](https://s040.gse.harvard.edu/unit7.html)</sup>
2. 选择底数并报告，因为底数虽不影响检验结果，但会影响回归斜率和截距。<sup>[6](http://biostathandbook.com/transformation.html)</sup>
3. 处理零值：对于少量零值（低于2%），可在取对数前加一个小常数；对于计数数据，惯例是加0.5；平方根变换在存在零值时仍然有效，倒数变换在无零值时可能有用。<sup>[6](http://biostathandbook.com/transformation.html)</sup><sup> • </sup><sup>[10](https://journals.sagepub.com/doi/10.1177/00045632211050531)</sup>
4. 检查适当性。在Box和Cox的羊毛数据示例中，\( \hat{\lambda} = -0.06 \)，置信区间为[-0.18, 0.06]，选择了对数变换；Shapiro-Wilk检验和扇形图（监测得分统计量以揭示异常值对 \( \lambda \) 的影响）是进一步的诊断工具。<sup>[10](https://journals.sagepub.com/doi/10.1177/00045632211050531)</sup><sup> • </sup><sup>[11](https://link.springer.com/chapter/10.1007/978-3-031-88365-1_6)</sup>
5. 谨慎回变换。以所选底数为底、以变换后的均值为指数作幂运算，得到的是几何均值而非算术均值：均值1.43（以10为底）和3.65（自然对数）分别回变换为26.9和38.5。<sup>[6](http://biostathandbook.com/transformation.html)</sup> 詹森不等式保证了这种不匹配：对于数值.01、.1、1、10、100，算术均值为22.222，但以10为底的对数均值为0，而 \( 10^0 = 1 \)。<sup>[2](https://s040.gse.harvard.edu/unit7.html)</sup> 即使 \( \ln(y) \) 恰好服从对数正态分布，预测值也需要用 \( \exp(\sigma^2/2) \) 进行调整，该调整量通常远大于1。<sup>[8](https://pure.au.dk/ws/files/307837131/Villadsen_Wulff_BJM_2021_AM.pdf)</sup>

平移常数至关重要。当1与数据量级相当时，加1后再取对数所得的值可能与 \( \log(y) \) 相差甚远；Carroll和Ruppert的细菌清除率示例（最大值为197,400时加0.05）对精确的平移量很敏感。<sup>[11](https://link.springer.com/chapter/10.1007/978-3-031-88365-1_6)</sup>

## 起源

对数变换在一个一般族中的地位由G. E. P. Box和D. R. Cox确立，他们1964年发表在《皇家统计学会杂志B辑》上的论文《变换分析》假设经过适当变换后正态、同方差、线性模型成立，并通过似然和后验分布进行推断。<sup>[12](https://doi.org/10.1111/j.2517-6161.1964.tb00553.x)</sup> 更早的1946年，M. S. Bartlett和D. G. Kendall在同一杂志上分析了对数变换与方差异质性。<sup>[13](https://doi.org/10.2307/2983618)</sup> 对于基因表达数据，Diana M. Kelmansky、Elena J. Martínez和Víctor Leiva于2013年在《遗传学与分子生物学中的统计应用》上提出了一个新的稳定方差变换族，其中包含一个广义对数成员。<sup>[14](https://doi.org/10.1515/sagmb-2012-0030)</sup>

## 变体

Box-Cox族定义为：当 \( \lambda \neq 0 \) 时 \( y(\lambda) = (y^{\lambda} - 1)/\lambda \)，当 \( \lambda = 0 \) 时为 \( \log y \)，其中 \( \lambda = 1 \) 表示不变换，\( \lambda = 1/2 \) 为平方根，\( \lambda = -1 \) 为倒数，从而避免了零点处的不连续；当 \( \lambda \to 0 \) 时，洛必达法则给出对数。<sup>[7](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)</sup><sup> • </sup><sup>[11](https://link.springer.com/chapter/10.1007/978-3-031-88365-1_6)</sup> 该族被扩展至可正可负的观测值，方法是在光滑性条件下对两类观测分别组合不同的Box-Cox变换；Yang的对偶变换 \( y(\lambda) = (y^{\lambda} - y^{-\lambda})/2\lambda \) 消除了该族的下界。<sup>[7](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)</sup>

对于具有加性方差成分的数据，普通对数变换失效：当 \( V(z) = a^{2} + b^{2} \cdot \mu^{2} \) 时，德尔塔方法给出 \( V(\ln z) \approx b^2 + a^2/\mu^2 \)，当 \( \mu \to 0 \) 时无界增长。<sup>[15](https://dmrocke.ucdavis.edu/papers/transcomp.pdf)</sup> 起始对数 \( g_c(z) = \ln(z + c) \)（其中 \( c > 0 \)）缓解了负观测值的问题，其方差从 \( \mu = 0 \) 时的 \( a^2/c^2 \) 变化到渐近值 \( b^2 \)。<sup>[15](https://dmrocke.ucdavis.edu/papers/transcomp.pdf)</sup> 广义对数（glog）\( f_c(z) = \ln((z + \sqrt{z^2 + c^2})/2) \)（其中 \( c = a/b \)）在一阶意义上稳定方差，当 \( z \) 较大时收敛于 \( \ln z \)，在针对微阵列数据比较的三个变换族中被评为最佳。<sup>[15](https://dmrocke.ucdavis.edu/papers/transcomp.pdf)</sup> 对于以伽马-泊松模型建模、过度离散为 \( \alpha \) 的单细胞RNA测序计数数据，均值-方差关系 \( \operatorname{Var}[Y] = \mu + \alpha \cdot \mu^{2} \) 给出平移对数 \( g(y) = \log(y + y_0) \)，其中伪计数 \( y_0 = 1/(4\alpha) \)。<sup>[16](https://www.nature.com/articles/s41592-023-01814-1)</sup>

## 应用

在临床化学中，对NHANES 2017-18尿液白蛋白数据进行log10变换后，得以进行有效的Welch t检验（t = 2.087，df = 1012.2，p = 0.0372），比较男性（中位数10.30 μg/mL）和女性（中位数9.10 μg/mL），尽管回变换后的均值（8.6和9.9 μg/mL）是几何均值而非算术均值（16.5和25.9 μg/mL）。<sup>[10](https://journals.sagepub.com/doi/10.1177/00045632211050531)</sup> 在回归教学中，对收入变量取对数同时改善了非线性和异方差性，并使残差更接近正态。<sup>[2](https://s040.gse.harvard.edu/unit7.html)</sup> 在单细胞基因组学中，一项对22种变换的基准测试发现，先进行简单的平移对数变换 \( \log(y/s + 1) \) 再进行主成分分析的表现与基于Pearson残差的变换等更复杂的替代方法相当或更好。<sup>[16](https://www.nature.com/articles/s41592-023-01814-1)</sup>

## 局限与替代方案

与流行观念相反，对数变换可能增加而非减少变异性（无论是否含异常值），且对对数变换后数据的检验通常与关于原始数据的假设无关。<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC4120293/)</sup> 对于方差与均值平方成比例的喇叭形残差模式，实现方差稳定可能以破坏线性为代价。<sup>[9](http://www.stat.umn.edu/hawkins/5302/Nonlinear%20Transformations%20and%20Variance%20Stabilizing%20Transformations.pdf)</sup> \( \log(x+c) \) 的变通方法还破坏了系数的通常乘性和加性解释。<sup>[2](https://s040.gse.harvard.edu/unit7.html)</sup> 系数解释本身带有近似性：\( \ln(X) \) 变化 \( p \) 等于 \( X \) 增加 \( (e^p - 1) \times 100\% \)，而非 \( p \times 100\% \)。<sup>[17](https://ar5iv.labs.arxiv.org/html/2106.03070)</sup>

近期工作缩小了常规取对数的适用情形。Chen和Roth表明，对于在零处定义的类对数变换（如 \( \log(1+Y) \) 和 \( \operatorname{arcsinh}(Y) \)），平均处理效应对 \( Y \) 的单位任意敏感：若处理影响外延边际，“只需重新缩放Y的单位，就能获得任意大小的处理效应。”他们建立了一个三难困境：对于零值结果，没有任何效应参数能同时是个体层面效应的平均值、尺度不变且点识别；他们推荐在替代方案中采用泊松回归和显式边际校准。<sup>[18](https://ar5iv.labs.arxiv.org/html/2212.06080)</sup> 一项2022年涵盖八种情景的模拟研究发现，当真实剂量-反应关系为线性时，对偏态自变量取对数会使效应估计产生偏倚（即使存在异常值也是如此），并建议不应仅因预测变量偏态就对其进行变换；模型选择应使用赤池信息准则等拟合统计量。<sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC9574910/)</sup>

主要替代方案直接对均值建模，而非变换结果变量。Villadsen和Wulff建议学者不要使用对数变换的因变量，而应使用带拟似然的广义线性模型，通过修正Park检验进行选择，这类模型无论方差模式如何都具有一致性，且能自然处理零结果。<sup>[8](https://pure.au.dk/ws/files/307837131/Villadsen_Wulff_BJM_2021_AM.pdf)</sup> 泊松型估计量甚至可用于非计数数据。<sup>[19](https://journals.sagepub.com/doi/10.1177/1094428121991907)</sup> 分歧尚未解决：Keene主张对数变换具有特殊优势，对数变换分析应经常优先选用，且该决策应在方案设计阶段考虑。<sup>[4](https://onlinelibrary.wiley.com/doi/10.1002/sim.4780140810)</sup> 一个实用的中间立场：仅在诊断支持下应用幂变换，因为变换不保证正态性，未经检验的变换可能导致方差分析结果不正确。<sup>[20](https://link.springer.com/article/10.1007/s10994-026-06994-3)</sup>

## References

1. [Data Transformations, Econ 114 Advanced Quantitative Methods](https://ealdrich.github.io/Teaching/Econ114/LectureNotes/transform.html)
2. [Unit 7 - Logarithmic Transformations to Address Assumption Violations (Harvard GSE)](https://s040.gse.harvard.edu/unit7.html)
3. [Log-transformation of independent variables: must we?](https://pmc.ncbi.nlm.nih.gov/articles/PMC9574910/)
4. [The log transformation is special (Keene, Statistics in Medicine, 1995)](https://onlinelibrary.wiley.com/doi/10.1002/sim.4780140810)
5. [Log-transformation and its implications for data analysis (Feng et al.)](https://pmc.ncbi.nlm.nih.gov/articles/PMC4120293/)
6. [Data transformations, Handbook of Biological Statistics](http://biostathandbook.com/transformation.html)
7. [Atkinson, Riani & Corbellini (2021), The Box-Cox transformation: review and extensions, Statistical Science 36(2), 239-255](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)
8. [Statistical myths about log-transformed dependent variables (Villadsen, Wulff, BJM 2021)](https://pure.au.dk/ws/files/307837131/Villadsen_Wulff_BJM_2021_AM.pdf)
9. [Nonlinear Transformations and Variance Stabilizing Transformations (U. Minnesota STAT 5302 notes)](http://www.stat.umn.edu/hawkins/5302/Nonlinear%20Transformations%20and%20Variance%20Stabilizing%20Transformations.pdf)
10. [Best practice in statistics: The use of log transformation (Annals of Clinical Biochemistry)](https://journals.sagepub.com/doi/10.1177/00045632211050531)
11. [Transformations (Springer chapter, Atkinson, Riani & Corbellini)](https://link.springer.com/chapter/10.1007/978-3-031-88365-1_6)
12. [G. E. P. Box, D. R. Cox (1964). An Analysis of Transformations. Journal of the Royal Statistical Society Series B (Statistical Methodology).](https://doi.org/10.1111/j.2517-6161.1964.tb00553.x)
13. [M. S. Bartlett, D. G. Kendall (1946). The Statistical Analysis of Variance-Heterogeneity and the Logarithmic Transformation. Journal of the Royal Statistical Society Series B (Statistical Methodology).](https://doi.org/10.2307/2983618)
14. [Diana M. Kelmansky, Elena J. Martínez, Víctor Leiva (2013). A new variance stabilizing transformation for gene expression data analysis. Statistical Applications in Genetics and Molecular Biology.](https://doi.org/10.1515/sagmb-2012-0030)
15. [Approximate Variance-Stabilizing Transformations for Gene-Expression Microarray Data (Rocke & Durbin)](https://dmrocke.ucdavis.edu/papers/transcomp.pdf)
16. [Comparison of transformations for single-cell RNA-seq data (Nature Methods, 2023)](https://www.nature.com/articles/s41592-023-01814-1)
17. [Linear Rescaling to Accurately Interpret Logarithms](https://ar5iv.labs.arxiv.org/html/2106.03070)
18. [Logs with zeros? Some problems and solutions (Chen & Roth)](https://ar5iv.labs.arxiv.org/html/2212.06080)
19. [Eight Simple Guidelines for Improved Understanding of Transformations and Nonlinear Effects](https://journals.sagepub.com/doi/10.1177/1094428121991907)
20. [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)

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

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/logarithmic-transformation

English original: https://www.edgepedia.org/logarithmic-transformation
