Learn
Mini widget·

Transforms & Log Transformation

Averaging in logs and converting back came out 24% low

Four hundred incomes have a mean of 484.8. The distribution is heavily right-skewed, so you take logs, average in log space, and exponentiate back to the original units. Out comes 369.8.

No arithmetic went wrong. What you converted back is not the mean — it is the geometric mean. On a skewed distribution that always sits below the arithmetic mean, and on this sample it is 23.7% lower. Report it as "average income" and you will be wrong in the same direction every single year.

How the same 400 incomes were summarisedValueWhat that value actually is
Add them up and divide by 400484.8the thing people normally mean by "average"
Log, average, exponentiate back369.8not the mean but the geometric mean — 23.7% lower

Going out through a transform and back in quietly changed which quantity you are reporting. Both rows come from the same data, and both get called "the average".

Transformation is the cheapest tool in statistics and the most casually misapplied. Knowing what you are trying to fix, and what quantity you end up reporting, removes most of the traps at once.

The key question

What does this transform straighten, and whose meaning does it change in exchange?

1

Concept

One rung on the ladder of powers

Three things a transform fixes

The purpose is not "to make the data normal". In practice a transform is always aimed at one of three quite separate problems.

Straighten the shape

skew → symmetry

A long right tail becomes a bell.

Straighten the relation

curve → line

An exponential trend becomes linear.

Even out the spread

fan → band

Residuals stop widening with the fitted value.

Change the meaning

difference → ratio
log b − log alog (b / a)

A gap in logs is a percentage change.

  • The shape of a distribution — a long right tail becomes roughly symmetric.
  • The relation between variables — a curve straightens, so a linear model becomes usable.
  • The spread of the residuals — errors that widen with the fitted value settle into a band.
  • The units of interpretation — a bonus, and an important one. A difference in logs is a percentage change.

Fixing one often improves the others, but not always. Deciding which one you are aiming at is what determines which transform to use and how strong to go.

The ladder of powers

The transforms in common use are not a grab bag — they sit on a single continuous ladder. You are raising x to a power p, and the further down you go, the stronger the correction.

,  x2,  x,  x,  logx,  1x,  1x,  \ldots,\; x^2,\; x,\; \sqrt{x},\; \log x,\; -\tfrac{1}{\sqrt{x}},\; -\tfrac{1}{x},\; \ldots

logx\log x occupies the rung at power 0. Not becausex0x^0 is useful — it is just 1 — but because the limit of(xp1)/p(x^p - 1)/p as p → 0 is exactly logx\log x. The log is not a separate idea; it is the value that fills the gap in the ladder.

Table 1 Skewness of the same 400 incomes at each rung
TransformPowerSkewnessStrength
x — untouched13.24none
√x — square root0.51.05mild
log x — logarithm0-0.07moderate
−1/√x — reciprocal root-0.5-0.93strong
−1/x — reciprocal-1-1.79strong

Raw skewness of 3.24 falls to 1.05 under the square root and reaches −0.07 at the log. Keep going and it becomes −0.93, then −1.79 — the tail has flipped to the other side. Descending the ladder does not monotonically help; there is a rung to stop on.

2

Why It Matters

Are you fixing the shape, the relation, or the spread?

Why the log works quite so often

Incomes, share prices, city populations, company revenues, reaction times — take logs of any of them and they come out near-symmetric. That is not luck. All of them are built by multiplying rather than by adding.

log(a×b)=loga+logb\log(a \times b) = \log a + \log b

A salary rising 3–7% a year is, after a decade, a starting salary multiplied by ten ratios. Products come out right-skewed. Take logs and the product becomes a sum — and sums drift toward normal by the central limit theorem.

That is what lognormal means

A distribution that becomes normal under logs is called lognormal; the name is the recipe. Whenever a quantity varies in percentage terms, lognormal is the first thing worth suspecting.

Interpretation often gets easier, not harder

Transforms have a reputation for making results hard to explain. The log frequently does the opposite: in a regression it turns coefficients into percentages, which is often the more natural unit to begin with.

ModelCoefficient reads asFor a small β
y ~ xx up 1 unit → y up β units
log y ~ xx up 1 unit → y up 100·β percentExact: (e^β − 1)·100
y ~ log xx up 1 percent → y up β/100 unitsDoubling x → y up 0.693·β
log y ~ log xx up 1 percent → y up β percentβ is an elasticity

The last row is the useful one. Log on both sides and the coefficient is an elasticity. "A 1% price rise cuts demand by 1.4%" is readable directly off a single number.

The trouble arrives on the way back

Average in transformed space, convert back, and what you get is not the mean in the original units. This is Jensen's inequality, and it applies to every convex or concave transform.

exp ⁣(1nlogxi)  =  xin    1nxi\exp\!\left(\frac{1}{n}\sum \log x_i\right) \;=\; \sqrt[n]{\prod x_i} \;\le\; \frac{1}{n}\sum x_i

On the same 400 incomes

Arithmetic mean: 484.8

Back-transformed log mean: 369.8 (the geometric mean)

Sample median: 386.1 — the geometric mean is close to it

What you recovered is not the mean but something near the median. On a lognormal distribution the geometric mean and the median coincide exactly.

To get the mean you need a smearing correction: multiply byexp(s2/2)\exp(s^2/2), where s is the standard deviation in log space. On this sample that factor is 1.322, and 369.8 × 1.322 = 488.8, close to the true 484.8.

3

How It Works

Deciding which way down the ladder, and how far

1. Picking a transform

The data looks likeTryWatch out for
Right-skewed, all positivelog xZeros break it — use log(x+1) or a shift
Right-skewed counts√xStabilises Poisson variance; gentler than log
Proportions between 0 and 1logitExact 0 and 1 have to be handled first
Left-skewedx², x³Go up the ladder, not down
Both signs, heavy tailsasinh xBehaves like log for large |x|, fine at 0
Nothing obviousBox–Cox / Yeo–JohnsonIt fits λ for you — but only on the training rows

2. Dealing with zeros and negatives

This is the log's hard constraint. log0\log 0 is undefined and so is the log of a negative. The reflex is log(x+1)\log(x+1), but that is not free.

ApproachWhen it is fineThe catch
log(x + 1)x runs in the tens to thousandsIf x is between 0 and 1, the +1 dominates
log(x + c), c estimatedZeros are a small minorityThe answer moves with your choice of c
Treat zero as missingZero means "not measured"Loses information if zero is real
asinh(x)Negative values are presentNearly identical to x when x is small
Yeo–JohnsonMixed signs and no clear callRequires estimating lambda

A lot of zeros may not be a transform problem

If 40% of the values are zero, that is not a skewed distribution — it is two processes stacked in one column. "Did they buy?" and "how much did they spend?" are different questions, and a two-part model is usually the right answer rather than any transform.

3. Letting Box–Cox choose

When the right rung is not obvious, the data can pick. Box–Cox estimates by maximum likelihood the λ that makes the result most nearly normal.

x(λ)={xλ1λλ0logxλ=0x^{(\lambda)} = \begin{cases} \dfrac{x^\lambda - 1}{\lambda} & \lambda \neq 0 \\[6pt] \log x & \lambda = 0 \end{cases}
  • Round λ to a recognisable rung — 0.03 means use the log, 0.48 means use the square root. An interpretable transform is worth far more than the fit you give up.
  • It needs strictly positive data — with negatives, use Yeo–Johnson instead.
  • Estimate λ on the training rows only — fitting it on everything lets the test set influence the transform.
  • It optimises normality alone — if your goal is straightening a relationship, Box–Cox may not be aiming at it.

4. When not to transform at all

Skew is not automatically a reason to transform. There are cases where leaving the data alone is clearly better.

SituationCallWhy
Using a tree-based modelUnnecessarySplits depend on order alone
You only care about predictionUsually unnecessaryNormality is not a prediction requirement
Large sample, comparing meansUnnecessaryThe CLT is already doing the work
Results must be in original unitsProceed carefullyConverting back changes what you report
The tail is the subject of interestDo notThe transform compresses what you came to study
4

Example

Back-transformed means are not means

In practice: ad spend against revenue

A scatter of ad spend against revenue curves upward. A straight-line regression gives an acceptable R2R^2, but the residuals fan out.

ModelResidualsWhat the coefficient says
revenue ~ spend0.71Fan out$2.30 of revenue per $1 of spend
log(revenue) ~ spend0.83Nearly even4.1% more revenue per $1,000 of spend
revenue ~ log(spend)0.79Wide on the left$1,800 more revenue per 1% of spend
log(revenue) ~ log(spend)0.89Even0.62% more revenue per 1% of spend

The fourth fits best and is also the easiest to state. A coefficient of 0.62 is an advertising elasticity, and because it is below 1 you can read diminishing returns straight off the same number.

The lesson here

A transform is not a trick for forcing a model to fit. If advertising genuinely works in proportional terms, then the log-log model is simply using the structure that is already there. It fits well because the model and the phenomenon agree.

In practice: the shortfall on the way back

A claims-severity model was trained in log space. Exponentiating the predictions and summing them produced an annual total that was persistently short.

Summed over 10,000 claims

Actual annual payout: $4.848M

Naive back-transform, summed: $3.698M

After the smearing correction: $4.888M

Before correcting, $1.150M was missing. Per claim it looks like rounding; across the book it moves the whole reserve calculation.

The gap does not close as the sample grows, because it is bias, not noise. Whenever a log-space model is used to predict a total in original units, the correction is mandatory.

Common misunderstandings

Misconception 1

❌ Skewed data always gets a log.

The ladder has several rungs and the log is one of them. With a skewness around 1 the square root is the better fit, and the log overshoots into the other tail.

Misconception 2

❌ The point of transforming is to make the data normal.

What regression asks to be normal is the residuals, not the variables. And when the goal is prediction, normality is not a requirement at all.

Misconception 3

❌ log(x+1) is the standard fix for zeros.

If x lives between 0 and 1, the +1 is larger than the data. The constant has to match the scale of the variable — and often asinh or a two-part model is a better answer than any constant.

Misconception 4

❌ Predict in log space, exponentiate, done.

Exponentiating gives you a prediction of the median. If you need a mean or a total, apply the smearing correction — without it you under-predict in the same direction every time.

Misconception 5

❌ Use whatever λ Box–Cox returns.

λ = 0.037 is uninterpretable to every reader you have. Round it to 0 and use the log — the loss in fit is negligible and the gain in explicability is not.

5

Interactive

Walk the ladder with one slider

Walk the ladder with one slider

The same 400 incomes under a single power. Moving left strengthens the correction — watch where the skewness crosses zero.

400 incomes, transformed by a single power. The log is not a special case — it is the rung at power 0.

Power

1

Skewness

3.24

Verdict

right tail

Untouched, the sample has a skewness of 3.24: a dense clump at the low end and a long thin tail to the right. Any mean-based method is going to struggle here.

Pick the rung that straightens the data — not the strongest one available.

What to look for

  • What is the raw skewness, and what shape does the histogram have?
  • How far does the square root pull it down? Far enough?
  • Which rung brings the skewness closest to zero?
  • Go below the log — what happens to the histogram?
  • Notice that the x-axis units change completely from rung to rung.

Learning points

Going further down the ladder does not keep helping — you can overshoot.

The log is not a special technique but the rung sitting at power 0.

After transforming, the horizontal axis is in new units — reporting means converting back.

Key takeaways

What it fixes

Shape, curvature, spreading residuals

  • Skew becomes symmetry
  • Curves become lines
  • Fanning residuals become a band

Why the log

It turns products into sums

  • Multiplicative data becomes additive
  • Differences become percentages
  • Zeros and negatives are undefined

What it costs

You now report a different quantity

  • Back-transforming a mean gives the median
  • Coefficients change meaning
  • Fit λ on the training rows only

The question is not "which transform should I use?"

It is "what quantity am I reporting once I have transformed?" Average in log space, convert back, and what you have is closer to a median than to a mean.

How does this apply to real data?

A transform is preprocessing and model design at the same time. In SKARI you can check the following alongside.

Transforms

Log, Square Root, Box–Cox, Yeo–Johnson

Checking shape

Histogram, Q-Q Plot, Skewness & Kurtosis

Residual diagnostics

Residual Plot, Breusch–Pagan, Scale-Location

Alternatives

GLM, Quantile Regression, Robust SE

Once this clicks, you can answer questions like these.

  • Am I fixing the shape, the relation, or the residuals?
  • Which rung of the ladder should this data stop on?
  • If there are zeros, are they real zeros or unmeasured?
  • Does reporting in original units need a correction?
  • Would a GLM be better than transforming at all?
Now try it on real dataOpen in Lab

Go Deeper

Scaling & Standardization