Box-Cox Transformations
Box-Cox Transformations: Estimating the Response Scale, Choosing lambda, and Reading the Result Back
A normal linear model assumes a mean linear in the predictors and constant error variance.
Under its other assumptions, exact finite-sample normal-model inference requires normally distributed errors; approximate normality may instead support approximate inference. The Box-Cox profile likelihood described here assumes normal errors on the transformed scale.
Real responses - costs, concentrations, durations, counts of area - often fail all three at once, and usually in a recognisable pattern: the spread of the residuals grows with the fitted value, and the residual distribution is right-skewed.
A response power transformation may improve increasing variance and right-skew together when a common mean-dependent scale mechanism produces both. But co-occurrence alone does not establish that mechanism, and right-skew alone does not imply heteroscedasticity.
For example, let ε = E - 1 for E ∼ Exp(1) independent of x, and let Y = μ(x) + ε with μ(x) > 1. Then Y stays positive, while the residuals have mean 0, variance 1, and skewness 2 at every fitted value.
Diagnose spread and shape separately when their causes are not known to be shared. Box-Cox turns the choice of response power into an estimation problem rather than a matter of taste.
The family
For a strictly positive response y, the Box-Cox family is
y(λ) = (yλ − 1)/λ for λ ≠ 0, and y(λ) = ln y for λ = 0
The exact scaled forms are 2(√y − 1) at λ = 0.5, 1 − 1/y at λ = −1, and y − 1 at λ = 1; at λ = 0 the form is ln y.
The first, second, and third are affine-equivalent to the conventional square-root, reciprocal, and untransformed-response model forms, respectively. The model fitted is a linear model for y(λ), not for y.
Note also that this transforms the response; transforming predictors is a different remedy aimed at a different defect.
Why the awkward form? Subtracting 1 and dividing by λ gives a continuous response transformation with limit ln y at λ = 0. Plain yλ tends to 1 for every y, so its raw response values collapse at the boundary.
The scaled form is a convenient way to evaluate the response across λ and puts the log case inside the family; continuity is not required for a usable profile likelihood.
For λ ≠ 0, the unscaled power with its matching Jacobian gives the same profile, and its adjusted profile has the same limit at zero.
Worked instance. Take y = 36.0. At λ = 0.5 the transformed value is (360.5 − 1)/0.5 = (6 − 1)/0.5 = 10.0. At λ = 0 it is ln 36 = 3.5835. Now check the continuity claim numerically at λ = 0.01: 360.01 = 1.03649, so (1.03649 − 1)/0.01 = 3.6485 - already close to ln 36 = 3.5835, and closing as λ shrinks further.
Plain yλ at λ = 0.01 would give 1.03649, also heading toward the same constant for every response.
One consequence of the scaling is worth noticing early. Because the −1 is a constant shift and the 1/λ a constant multiplier, the family applies an affine rescaling on top of the power.
Fitting a linear model to (yλ − 1)/λ and to yλ at the same λ gives the same residual pattern and the same R2.
Across values of λ the 1/λ factor does change the raw residual sum of squares, so SSE by itself is not comparable from one λ to the next.
It does not change the likelihood: each parameterisation carries its own Jacobian, and the extra −n ln|λ| that writing the response as yλ introduces into the SSE term is cancelled exactly by the n ln|λ| its Jacobian contributes, so the profile log-likelihoods agree for each nonzero λ, and the correctly adjusted unscaled profile has the same limit at λ = 0. The scaled form is preferred because it provides a continuous, convenient response transformation with limit ln y; likelihood validity does not depend on that scaling.
Estimating λ
λ is chosen by maximum likelihood under the assumption that y(λ) follows a normal linear model. Profiling out the regression coefficients and the error variance leaves
ℓ(λ) = −(n/2) ln[SSE(λ)/n] + (λ − 1) Σ ln yi
where SSE(λ) is the residual sum of squares from regressing y(λ) on the predictors.
The second term is the log-Jacobian of the transformation, and it is not optional: without it, the likelihood could be made arbitrarily large simply by choosing a λ that shrinks the response scale, and SSE alone is not comparable across values of λ.
In practice one evaluates ℓ(λ) on a grid and reads off the maximiser.
A confidence interval comes from the profile likelihood rather than from a standard error. The set
{λ : ℓ(λ) ≥ ℓ(λ̂) − ½χ21,0.95} = {λ : ℓ(λ) ≥ ℓ(λ̂) − 1.92}
is an approximate 95% interval, since 3.841/2 = 1.92. The drop is half the chi-square quantile because the likelihood ratio statistic is twice the log-likelihood difference.
Worked instance. Suppose a grid search gives λ̂ = 0.09 with ℓ(λ̂) = −148.72. The cutoff is −148.72 − 1.92 = −150.64, and reading where the profile curve crosses that level gives an interval of about (−0.14, 0.31).
Reporting λ̂ or choosing a familiar transformation
Reporting λ̂ = 0.09 directly and fitting the corresponding Box-Cox transformation is valid. Alternatively, choosing a familiar value inside the confidence interval is an optional simplification, not a requirement.
Here 0 lies inside the stated interval (−0.14, 0.31), so the log transform is supported as a familiar choice; if adopted, the model is reported as a model for ln y.
The 95% interval does not include 0.5 or 1, so these values are not supported within the assumed Box-Cox normal linear model.
Conditional on an adequate mean structure, exclusion of 1 is evidence against leaving the response untransformed; it does not by itself establish that response transformation is preferable to revising the mean, variance, or error model.
The gain is interpretability. A model for ln y gives familiar proportional-change interpretations: for a unit predictor change, exp(β) is the fitted multiplicative factor, holding other predictors fixed.
At λ = 0.09, coefficients still describe changes in the fitted transformed response (y0.09 − 1)/0.09. For a fitted transformed value z with 1 + 0.09z > 0, the inverse gives y = (1 + 0.09z)1/0.09; those coefficients are mathematically interpretable, though less immediately familiar.
The cost is that the interval is being used to license a choice, and the reported inference afterwards treats that choice as if it had been made in advance.
Reading results on the transformed scale
Once the model is fitted to ln y, everything it produces lives on the log scale, and moving back is not simply a matter of exponentiating.
If ln y has a normal distribution with mean μ and variance σ2, then exp(μ) is the median of y, while the mean of y is exp(μ + σ2/2).
The two differ by the factor exp(σ2/2), which is exactly the skew the transformation was introduced to handle.
Worked instance. A fitted value on the log scale is 2.50 with residual variance σ̂2 = 0.26. Back-transforming directly gives exp(2.50) = 12.182, an estimate of the median response.
The estimated mean is exp(2.50 + 0.13) = exp(2.63) = 13.874, larger by a factor of exp(0.13) = 1.139. Reporting 12.182 as "the predicted average" understates the mean by about 12%, and the error grows with σ̂2.
Similarly, a symmetric prediction interval on the log scale back-transforms to an asymmetric interval for y, which is correct rather than a defect: the endpoints are still the right quantiles, because exponentiating is monotone.
Limits and mean structure
- The ordinary full family needs y > 0. It includes ln y and allows arbitrary real powers, even though some individual powers are defined for non-positive responses, for example, at λ = 1 the expression is y − 1. Adding an arbitrary constant before transforming is common and consequential, since λ̂ depends on the shift; a shift parameter estimated jointly, or the Yeo-Johnson family, which is defined on the whole real line, is preferable.
- It does not generally supply missing mean terms. Box-Cox cannot in general replace an omitted predictor or interaction. But some curvature on the raw response scale can disappear after transforming the response: for example, if Y = exp(a + bX + ε), then log Y = a + bX + ε is linear in X. Diagnose the mean structure on the chosen response scale; add missing terms or consider an appropriate predictor or response transformation as the pattern warrants.
- It is not robust. A few extreme observations can dominate SSE(λ) and drag λ̂ toward whatever value shrinks them. A λ̂ far from any interpretable value is often a signal to look for outliers rather than to adopt the estimate.
- It targets the errors, not the marginal distribution of y. The likelihood is built on the residuals of the linear model, so the relevant check is the residual distribution after transforming, not a histogram of the raw response - which can legitimately be multimodal or skewed if the predictors are.
- λ is estimated, so later inference is conditional on it. Standard errors, p-values and intervals from the final model condition on the chosen λ and omit its selection uncertainty. The effect on reported uncertainty and calibration depends on the setting.
- Fits at different λ are not directly comparable. Residual sums of squares and R2 values computed on different response scales measure variation in different units; the Jacobian term in the profile likelihood exists precisely to make the comparison legitimate.
Diagnosing which assumption has failed in the first place, and the other available remedies once it has, belong to the neighbouring diagnostic concepts. The question here is how this particular family is estimated, chosen and read.
The Box-Cox family is written as y(λ) = (yλ − 1)/λ for λ ≠ 0, rather than simply as yλ. What is the main reason for the scaled form?
A Box-Cox analysis selects λ = 0.25, so each response value is transformed as y(λ) = (yλ − 1)/λ. Two observations have responses y1 = 16.0 and y2 = 81.0. Compute the difference between their transformed values, y2(λ) − y1(λ). Give your answer as a decimal number.