Can a set of numbers that includes positives, zeros, and negatives still receive a power transform? Yeo–Johnson's answer is to use a single parameter λ with linked expressions on either side of zero. The two sides meet at the origin; order is preserved, but spacing between neighboring values can change.[1]

One parameter, four branches

Write the transform as Tλ(x). Split first by whether the input is negative; on each side, give a separate logarithmic form for the limit when the denominator approaches zero:[1]

Tλ(x)={(1+x)λ−1λ,x≥0, λ≠0,log⁡(1+x),x≥0, λ=0,−(1−x)2−λ−12−λ,x<0, λ≠2,−log⁡(1−x),x<0, λ=2.T_\lambda(x)=\begin{cases} \dfrac{(1+x)^\lambda-1}{\lambda}, & x\geq 0,\ \lambda\ne 0,\\[6pt] \log(1+x), & x\geq 0,\ \lambda=0,\\[6pt] -\dfrac{(1-x)^{2-\lambda}-1}{2-\lambda}, & x<0,\ \lambda\ne 2,\\[6pt] -\log(1-x), & x<0,\ \lambda=2. \end{cases}

The logarithmic branches are continuous limits of the corresponding power functions: as λ approaches 0 on the positive side one obtains log(1+x), and as λ approaches 2 on the negative side one obtains −log(1−x). Thus λ=0 does not put the whole real line on a logarithm; neither does λ=2. On the negative side the exponent is 2−λ, and there is also a leading minus sign.

This pairing has a convenient mirror relation: for positive x, Tλ(−x)=−T₂₋λ(x). The negative side can be read as applying parameter 2−λ to the positive distance and reflecting the result back. A single λ can therefore bend the two sides in different directions.

How the sides join at zero, and why order is preserved

For any λ, Tλ(0)=0. The sides meet continuously at the origin and their slopes match: the positive-side derivative is (1+x)^(λ−1) and the negative-side derivative is (1−x)^(1−λ); both equal 1 at zero. Both derivatives stay positive in their regions, so larger inputs yield larger outputs.

λ=1 is a clear reference: for any input, T₁(x)=x, so the curve is the identity line. When λ is less than 1, the slope on the positive side decreases as one moves right, compressing distances among positives; on the negative side the slope increases as one moves left, stretching distances among negatives. When λ exceeds 1, the trends reverse.

Watching the change on a fixed array

Take twelve fixed constructed values: −3, −1, −0.5, 0, 0.1, 0.4, 0.8, 1, 2, 4, 8, 16. Fitting this array yields λ≈0.461. After substitution, −3 becomes about −4.836 and −1 about −1.238; on the other side, 4 becomes about 2.387 and 16 about 5.841. Zero remains zero, and the order of all values matches the original.

Spacing makes the effect clearer: the original gap from 4 to 16 is 12 and becomes about 3.454 after the transform; the original gap from −3 to −1 is 2 and becomes about 3.598. That is compression on the positive side and stretch on the negative side when λ is less than 1. Ranking is unchanged, but distances on the number line no longer scale uniformly.

Three panels show transform curves at different parameters, transformed fixed values, and the likelihood curve

Actual curves of the four-branch formula on positive and negative inputs, together with the transform of the twelve fixed constructed values and a recomputed profile likelihood that includes the Jacobian; λ=1 is the identity map, and a fitted λ does not prove that the data are normal.

How the fitted λ is chosen

When λ is not supplied, SciPy's yeojohnson chooses the parameter by maximum likelihood and returns the transformed array together with the fitted value.[1] For the fixed array above, the result is about 0.461. The right-hand curve in the figure shows the profile log-likelihood over candidate λ values; the peak neighborhood matches this fit.

The choice is not simply minimizing the variance after the transform. Let σ̂² be the maximum-likelihood variance of the transformed values, dividing by n rather than n−1; after dropping constants that do not depend on λ, SciPy's profile log-likelihood is:[2]

ℓ(λ)=−n2log⁡(σ^2)+(λ−1)∑i=1nsign⁡(xi)log⁡(1+∣xi∣).\ell(\lambda)=-\frac{n}{2}\log(\hat\sigma^2) +(\lambda-1)\sum_{i=1}^{n}\operatorname{sign}(x_i)\log(1+|x_i|).

The first term moves with the variance of the transformed data; the second is the Jacobian term from the change of variables and reflects how the number line is compressed or stretched at each location. Both terms must be used when comparing λ values. Looking only at variance changes the objective and can select a different parameter.

Thus λ≈0.461 should be read as: under these inputs and this Gaussian working likelihood, it maximizes the profile log-likelihood in use. It describes a data-driven choice of transform, not a proof about the distribution. In practice one should first decide which variable to adjust and why, then judge usefulness with model diagnostics and predictive performance.

References

  1. [1] SciPy. scipy.stats.yeojohnson. SciPy v1.18.0 Manual.

  2. [2] SciPy. scipy.stats.yeojohnson_llf. SciPy v1.18.0 Manual.