Transformations & Recoding
Before analysis, raw numbers often need reshaping: not the table's layout, but the values themselves. A right-skewed variable can be pulled toward symmetry; scores on different scales can be put on common footing; reverse-worded survey items must be flipped before they're combined. Done well, these steps help the analysis meet its assumptions and compare like with like. Done carelessly, like slicing a continuous variable in half, they throw information away.
Taming skew: log and square root
Many measurements (income, reaction times, counts, concentrations) pile up near a floor of zero and trail off into a long right tail. That skew can violate the normality that t-tests and regression lean on and let a few large values dominate. A monotonic transform compresses the big values more than the small ones:
- log(x): the strongest common squeeze; turns multiplicative structure into additive. Needs strictly positive values (use
log(x + 1)if zeros appear). - √x: gentler; a classic choice for counts.
The cost is interpretation: results are now on the log or root scale. The mean of the logs back-transforms to the geometric mean, which is below the arithmetic mean, so report both and say which you used.
Which rung of the ladder?
Log and root are two rungs of one ladder of powers, indexed by an exponent λ that runs from strong squeezing at the bottom to none in the middle:
| λ | Transform | Effect on a right-skewed variable |
|---|---|---|
| 1 | leave it alone | skewness 4.74 |
| 0.5 | √x | skewness 1.60, pulled in but still skewed |
| 0 | log x | skewness −0.03, symmetric |
| −1 | 1 ÷ x | skewness −5.51, overshot into left skew |
Those numbers come from one right-skewed sample of 2,000 values, and they show that you can go too far. Reciprocal doesn't fix a skew that log already fixed. It reverses it.
The Box–Cox method picks λ for you: it finds the exponent that makes the transformed values look most normal. On log-normal data it gives λ̂ = 0.01. On data built as a squared normal it gives about 0.4, and on data that is already normal it gives about 1, meaning no transformation is needed. In R it is MASS::boxcox(lm(y ~ 1)).
Look at the interval it draws, not just the peak. λ̂ is an estimate like any other, so round it to the nearest interpretable rung. Reporting "we applied a Box–Cox transform with λ = 0.407" claims a precision that a quantity with a confidence interval half a unit wide does not have. Across 2,000 right-skewed samples of n = 60, a typical thesis size, the interval had a median width of 0.50 and never once included 1. So Box–Cox is reliable about whether to transform, even when it is vague about which rung. On already-normal samples of the same size the interval was 2.33 wide and included 1 in 97% of runs.
Below is a right-skewed income variable. Flip between the raw values and each transform, and watch the histogram and the Q–Q plot (points on the diagonal = normal) respond. Notice the skewness number, and that z-scoring does nothing to the shape.
🔧 Transformation Gallery
One skewed dataset, four views. The histogram shows the shape; the Q–Q plot shows how close it is to normal (a straight diagonal is perfect). Skewness near 0 is symmetric.
Standardizing, reverse-coding, composites
- z-standardizing:
(x − mean) / SDputs a variable in SD units (z-scores), so variables on different scales become comparable and regression coefficients read as "per SD". It's a linear shift-and-stretch: it changes the units, never the shape or the skew. - reverse-coding: on a 1–5 scale, a negatively worded item is flipped with
6 − xso that "high" means the same thing for every item. Skip it and the reversed items silently cancel the others, deflating a scale's reliability (see Cronbach's α). - composite scores: once every item points the same way, average (or sum) them into one score per person. A mean handles missing items more gracefully than a sum.
The tempting mistake: median splits
It's common to take a continuous predictor and chop it at the median into "high" vs "low" — it feels tidy and lets you run a t-test. But collapsing a continuous variable to two values discards the differences within each half: everyone above the median is treated as identical. The result is a weaker correlation and a real loss of power. Theory says that for a normally distributed predictor, splitting at the median shrinks a correlation to about 0.80 of its value, which removes roughly a third of the variance it explains. Watch it happen:
✂️ The Cost of a Median Split
A continuous predictor X and an outcome Y. Toggle the median split to replace X with a crude high/low flag, and watch the correlation drop, and with it the information you can actually use.
Transform to fix a shape, recode to fix a meaning, and keep continuous variables continuous. A log or root can fix a skewed variable without losing a single data point. A median split gains you nothing and costs you power and precision. If you need groups for a plot, make them, but analyze the numbers.
Why it matters: the right transform can make a violated assumption hold and stop a handful of extreme values from dominating the result, while keeping every observation. Do it in a script, on the clean data, so the step is documented and reversible. Always report the scale you analyzed on and back-transform your summaries for the reader. And avoid the median split, which only ever loses information.
These are the same operations seen from the data-preparation side. Sometimes the reason for transforming is a curved relationship in a regression, not a skewed variable. Non-Linear Relationships & Transformations in Stats 2 covers that case: reading the curvature off a residual plot, and interpreting a coefficient once the variable is logged.
Common questions
When should I log-transform my data?
Reach for a log when a variable is strongly right-skewed and strictly positive (income, reaction times, counts, concentrations), especially when its structure is multiplicative (a 10% change matters more than a fixed amount). A log often restores the normality and constant variance that tests assume, and pulls in a long tail so a few large values stop dominating. If the variable contains zeros, use log(x + 1). The trade-off is interpretation: results are now on the log scale, so report that and back-transform your summary to the geometric mean.
I analyzed my outcome on the log scale. How do I report the means?
Do the statistics on the logged values, then exponentiate the summary to put it back in units your reader understands. What comes back is the geometric mean, which is below the arithmetic mean on right-skewed data. In one sample of 120 incomes the arithmetic mean was 37,832. The mean of the logs was 10.23, with a 95% CI of [10.08, 10.37], which back-transformed to a geometric mean of 27,625 with a CI of [23,941, 31,876]. The back-transformed interval is not symmetric: it reaches 3,684 below the estimate and 4,251 above. Leave it that way rather than averaging the two into a tidy ± figure. Another consequence catches people out in the results section. Differences on the log scale become ratios after back-transforming, so a gap of 1 log unit is a factor of 2.72, not a gain of 2.72 units. State in the Method which scale you analyzed on.
Do I have to reverse-code items before averaging them into a scale?
Reverse-code first, always. If a questionnaire mixes positively and negatively worded items ("I feel calm" alongside "I feel tense"), the negative ones run in the opposite direction. Average them in raw and they partly cancel the others, which lowers both the scale's reliability and its validity. Flip each reverse item with 6 − x on a 1–5 scale (or max + min − x in general) so every item points the same way, then compute the composite. Recompute Cronbach's α afterwards to confirm the items now hang together.