Tutorials › Regression Analysis (Undergraduate) › Yeo-Johnson Transformations for Signed Variables

Transforming Predictors and Outcomes · Tutorial 410 of 991

Yeo-Johnson Transformations for Signed Variables

Learn to calculate Yeo-Johnson transformed values for positive, zero, and negative data, and understand what the transformation does—and does not—make easier to interpret.

Intermediate 9 min read

What You'll Learn

  • State the Yeo-Johnson formula for nonnegative and negative values
  • Calculate transformed values for common choices of the power parameter
  • Explain the special cases at power parameters zero, one, and two
  • Understand why the transformation can accommodate signed data
  • Recognize how transformation choices affect interpretation and depend on measurement scale

Why a Transformation for Signed Data?

Power transformations can change the shape of a predictor or outcome before it is used in a regression model. The Box-Cox family requires positive values, so it cannot be applied directly when a variable includes zero or negative observations. The Yeo-Johnson family addresses that limitation: it is defined for every real input, while using different formulas on the two sides of zero.

This flexibility is useful, but it does not make the transformed values automatically easy to interpret. A power parameter controls the transformation, and the positive and negative branches need not behave as mirror images. It is therefore important to calculate the appropriate branch, understand special parameter values, and keep the original scale in view.

Definition: For a real-valued variable \(y\) and power parameter \(\lambda\), the Yeo-Johnson transformation is $$ T_\lambda(y)= \begin{cases} \displaystyle \frac{(y+1)^\lambda-1}{\lambda}, & y\geq 0,\ \lambda\neq 0,\\[6pt] \log(y+1), & y\geq 0,\ \lambda=0,\\[6pt] \displaystyle -\frac{(1-y)^{2-\lambda}-1}{2-\lambda}, & y<0,\ \lambda\neq 2,\\[6pt] -\log(1-y), & y<0,\ \lambda=2. \end{cases} $$ Here \(\log\) denotes the natural logarithm. The transformation is defined at zero, where \(T_\lambda(0)=0\) for every \(\lambda\).

Using the Two Branches

First determine whether the observed value is nonnegative or negative. For a nonnegative value, use the branch involving \(y+1\); for a negative value, use the branch involving \(1-y\). The separate logarithmic expressions apply when the power parameter makes a denominator zero: \(\lambda=0\) on the nonnegative branch, and \(\lambda=2\) on the negative branch.

The added 1 lets the formulas accept zero and, on the negative branch, keeps \(1-y\) positive. It is not a license to use the wrong branch: the transformation is piecewise, and a negative observation must be calculated with its negative-value formula. At \(y=0\), the nonnegative branch gives zero directly.

Worked Example: Applying Both Branches at \(\lambda=0.5\)

Suppose a hypothetical variable is recorded as \(-3\), \(0\), and \(3\), in a stated measurement scale. Transform each value using \(\lambda=0.5\).

For \(y=3\), use the nonnegative branch:

$$ T_{0.5}(3)=\frac{(3+1)^{0.5}-1}{0.5} =\frac{\sqrt{4}-1}{0.5} =\frac{2-1}{0.5} =2. $$

For \(y=-3\), use the negative branch:

$$ T_{0.5}(-3) =-\frac{(1-(-3))^{1.5}-1}{1.5} =-\frac{4^{1.5}-1}{1.5} =-\frac{8-1}{1.5} \approx -4.667. $$

Finally, \(T_{0.5}(0)=0\). The transformed values for \(3\) and \(-3\) are not opposites: \(2\) and approximately \(-4.667\). This illustrates why the two branches should not be assumed to produce symmetric results.

Special Values of the Power Parameter

Some choices of \(\lambda\) make the transformation especially simple. When \(\lambda=1\), both branches reduce to the identity transformation: \(T_1(y)=y\). Thus this choice makes no change to the variable. When \(\lambda=0\), the nonnegative branch is \(\log(1+y)\), but negative observations still use the other branch. When \(\lambda=2\), the negative branch is \(-\log(1-y)\), while nonnegative observations use their power formula.

The logarithmic cases are the limits of the power formulas, rather than unrelated add-ons. For the nonnegative branch, the limit as \(\lambda\) approaches zero is:

$$ \lim_{\lambda\to 0}\frac{(1+y)^\lambda-1}{\lambda} = \lim_{\lambda\to 0}\frac{e^{\lambda\log(1+y)}-1}{\lambda} =\log(1+y). $$

The last equality follows from the standard limit \(\lim_{u\to 0}(e^u-1)/u=1\), with \(u=\lambda\log(1+y)\). For the negative branch, set \(q=2-\lambda\). As \(\lambda\) approaches 2, \(q\) approaches zero, giving:

$$ \lim_{\lambda\to 2}-\frac{(1-y)^{2-\lambda}-1}{2-\lambda} = -\lim_{q\to 0}\frac{(1-y)^q-1}{q} =-\log(1-y). $$

These limits explain why the formula changes to a logarithm at the two exceptional parameter values.

Worked Example: Calculating Values at \(\lambda=0\)

For hypothetical values \(y=2\), \(y=0\), and \(y=-2\), calculate the Yeo-Johnson transformation at \(\lambda=0\). Use the logarithmic branch for \(y=2\), the zero property for \(y=0\), and the negative branch for \(y=-2\).

For \(y=2\):

$$ T_0(2)=\log(2+1)=\log(3)\approx 1.099. $$

At zero, \(T_0(0)=0\). For \(y=-2\), the negative branch has \(2-\lambda=2\), so:

$$ T_0(-2) =-\frac{(1-(-2))^2-1}{2} =-\frac{3^2-1}{2} =-\frac{8}{2} =-4. $$

Although the positive-side formula is logarithmic here, the negative-side formula is not. Applying \(\log(1+y)\) to the negative value would both use the wrong branch and fail to give a real logarithm, since \(1+(-2)<0\).

Worked Example: Identity at \(\lambda=1\)

A hypothetical measurement takes the values \(-2.5\), \(0\), and \(4\). Transform them at \(\lambda=1\) to see why this parameter leaves every value unchanged.

For \(y=4\), the nonnegative branch gives:

$$ T_1(4)=\frac{(4+1)^1-1}{1} =\frac{5-1}{1}=4. $$

For \(y=-2.5\), the negative branch gives:

$$ T_1(-2.5) =-\frac{(1-(-2.5))^{1}-1}{1} =-(3.5-1) =-2.5. $$

Zero remains zero, so the three transformed values are \(-2.5\), \(0\), and \(4\). This identity case is a useful check on calculations and a reference point when considering other powers.

What the Transformation Changes

For any fixed real \(\lambda\), the Yeo-Johnson transformation is increasing on both branches and joins continuously at zero. In fact, its first derivative is positive: for \(y>0\), it is \((1+y)^{\lambda-1}\), with the same positive value \(1/(1+y)\) at \(\lambda=0\); for \(y<0\), it is \((1-y)^{1-\lambda}\), with the same positive value \(1/(1-y)\) at \(\lambda=2\). At zero, the derivative from either side is 1. Thus larger original values remain larger after transformation; the transformation changes spacing and shape, not the ordering of observations.

If a transformed variable is used as an outcome, regression coefficients describe changes in transformed-outcome units, not directly in the original outcome units. Recovering predictions on the original scale requires applying the inverse transformation, and interpreting those predictions depends on what quantity the model represents. If a predictor is transformed, its coefficient likewise refers to a change in the transformed predictor. These are changes in the scale of the model, not evidence that the original-scale effect is constant.

The power parameter controls how spacing changes as values move away from zero. A value of \(\lambda=1\) leaves the data unchanged; other choices alter the curvature of the transformation. The branches do not have to respond equally to positive and negative values, as the first worked example showed. Consequently, a single \(\lambda\) does not imply symmetric compression or expansion around zero.

Choosing and Reporting a Transformation

A transformation should be chosen for a clear modeling purpose, such as making a relationship more nearly linear or improving the behavior of model residuals. The Yeo-Johnson family allows analysts to consider such a change without first requiring all observations to be positive. It does not guarantee that any particular regression assumption will hold, and applying it does not by itself establish a suitable model. The transformed relationship and the model’s remaining assumptions still need to be assessed.

In applied work, software may select or estimate \(\lambda\) using a criterion tied to the regression model. The choice is not a universal property of the variable: it depends on the modeling context and on how the variable is recorded. In particular, the “1” in \(y+1\) and \(1-y\) means that the numerical measurement scale matters. Recording the same underlying quantity in different units can change the transformed values. State the units, the value of \(\lambda\), and the transformation used when reporting results.

Key takeaway: Yeo-Johnson transforms real-valued data by applying one power formula to nonnegative values and another to negative values. It includes zero and has useful logarithmic special cases, but the two branches can behave differently, and model interpretations remain tied to the transformed scale.

Common Mistake

Wrong reasoning: “The value is negative, so I can use the positive-branch formula with \(y+1\), or just take its logarithm after adding 1.” This is not the Yeo-Johnson definition; it may also produce an undefined logarithm or an incorrect numerical result. Correction: identify the sign first, then use the corresponding branch and its special case if \(\lambda=0\) or \(\lambda=2\). For example, at \(\lambda=0\), \(y=-2\) transforms to \(-4\), not to \(\log(-1)\).

Check Your Understanding

Use the sign-specific formula and show your arithmetic where a calculation is requested.

  1. At \(\lambda=0.5\), which branch applies to \(y=-1\), and what is its transformed value?
  2. Why does \(T_1(y)=y\) for both positive and negative \(y\)? Verify this for \(y=2\) and \(y=-2\).
  3. At \(\lambda=2\), which branch uses a logarithm? Write the formula for that branch.
  4. Explain why applying \(\log(1+y)\) to a negative observation is not a substitute for using the Yeo-Johnson negative branch.
  5. Name two details that should be reported so a reader can understand a fitted Yeo-Johnson transformation.