When Data Aren't Normal - Fix It!
By the end of this module, you will:
You've diagnosed non-normality. Now what?
In previous modules, you learned to detect non-normal data. But what do you actually DO about it?
Three options:
Today, we'll explore transformationsโmathematical operations that can "fix" skewed data.
Imagine reaction times: 200ms, 400ms, 800ms, 1600ms
Original data:
After log transformation:
Result: The log transformation "pulls in" extreme values proportionally, creating symmetry!
| Type of Skew | Transformation | Formula | When to Use |
|---|---|---|---|
| Right Skew (long tail right) |
Log | log(x) | Reaction times, income, counts |
| Right Skew (mild) |
Square Root | โx | Count data, mild skew |
| Left Skew (long tail left) |
Square | xยฒ | Proportion data near 1 |
| Left Skew | Reflect + Log | log(max - x + 1) | When square doesn't work |
โ ๏ธ Important: Log and square root require all values > 0. If you have zeros or negatives, add a constant first!
Before you run anything. In Part 4 you will take a set of right-skewed reaction times and try three transformations on them: square root, log, and reciprocal (1/y).
The reciprocal is the most aggressive of the three — it compresses large values harder than either of the others.
Predict: which will do the best job of making these data normal?
Second prediction. A classmate says: "I z-scored my reaction times, so now they're normal." Will z-scoring fix the skew? Say why or why not before you check.
Open Posit Cloud. These are the same hist(), shapiro.test(), and
skewness() tools from Chapter 11, plus Chapter 12's transformations.
Sixty reaction times from a caffeine study. Reaction times are the textbook case for transformation: bounded below by zero, with a long tail of slow responses.
Skewness 1.39 against Chapter 11's |skew| < 0.5 threshold, and Shapiro-Wilk p = .0001. These data need help.
Chapter 12's advice is to work through the candidates and compare, not to guess once. Apply all three, then look at all four histograms together.
Question 1: Record what you got. (Enter p as a decimal.)
| Version | Shapiro p | Skewness |
|---|---|---|
| Raw | ||
| Square root | ||
| Log | ||
| Reciprocal |
Log wins, and it is not close. Skewness −0.019, Shapiro-Wilk p = .999. That is what a transformation looks like when it is the right one.
Square root helped, but not enough. It clears p > .05 (p = .155), which is why it is tempting to stop there — but its skewness is 0.667, still over Chapter 11's 0.5 line. The test and the descriptive disagree, and when they do, look at the histogram.
Now the surprise: the reciprocal did essentially nothing. Skewness went from 1.388 to 1.353. The most aggressive transformation was the least effective one.
There is a clean reason. These reaction times are lognormal — that is what
rlnorm() generates, and it is roughly what real reaction times look like. If
Y is lognormal then 1/Y is also lognormal, just with the
sign of the log-mean flipped. The reciprocal cannot fix this skew because it maps the
distribution family onto itself. Strength was never the point; matching the shape
is.
Question 2: Was your Part 3 prediction right? Explain why "more aggressive" turned out not to mean "more effective."
Question 3: The square root gave p = .155 (passes) but skewness 0.667 (fails Chapter 11's threshold). If you only had one of those two numbers, which would you rather have, and what would you do with a disagreement like this?
Now test your second prediction.
Not similar. Identical — to twelve decimal places.
Z-scoring subtracts a constant and divides by a constant. That slides the distribution along the number line and changes its width. It cannot bend it. Skewness is a shape statistic and is unchanged by any linear rescaling, which is why the Shapiro-Wilk output is byte-for-byte the same.
Z-scoring is genuinely useful — for putting variables with different units on a common scale, or for comparing regression predictors. It is simply not a normality fix, and Chapter 12 lists it in the common-errors table for exactly this reason.
Question 4: Your classmate is not convinced. Using the two skewness values, write the one-sentence explanation that would actually change their mind.
One recording glitch logged a reaction time of 0 ms. Watch what the log does with it.
log(0) is -Inf, and one -Inf makes the
mean of the whole variable -Inf. Every downstream statistic is then garbage, and
R will not warn you — it will just quietly return -Inf or NaN.
log(y + 1) is the standard fix, and it changes the interpretation slightly: you
are now modelling log(RT + 1 ms), not log(RT). Say so in the write-up. And before you reach
for it, ask whether a 0 ms reaction time is real data or a recording error that should be
removed.
Log won. Run the analysis on log_rt, not on the raw variable.
"The groups differ by 0.365 log-milliseconds" is true and useless. Convert it.
On the log scale a difference becomes a ratio. exp(0.365) = 1.44, so placebo reaction times are about 44% longer than caffeine ones. That is a sentence a reader can use, and it is the honest translation of a log-scale result.
Note the back-transformed means (240.5, 346.4) are lower than the raw arithmetic means (260.7, 384.2). Back-transforming a mean log gives you the geometric mean, which for skewed data sits below the arithmetic mean. That is not an error — it is a different, and for skewed data often more representative, summary. Just do not label it as the arithmetic mean.
Question 5: In your own words, explain WHY the log transformation works for right-skewed data. What does it do to large vs. small values?
Question 6: Write the APA-style sentence reporting this analysis. It must name the transformation, say what prompted it, give the test result, give the effect size, and state the scale. Use the back-transformed ratio to make the size human-readable.
Question 7: Your results are in log(reaction time) units. A reader asks "so how much faster was caffeine, in milliseconds?" Answer them — and explain why that question is harder than it sounds.
1. Bimodal Distributions
Two peaks = two groups. Transformation won't fix thisโyou need to analyze groups separately or investigate why there are two distributions.
2. Categorical/Ordinal Data
Likert scales (1-5 ratings) shouldn't be transformed. Use non-parametric tests or treat as ordinal.
3. When You're "P-Hacking"
Don't try 10 different transformations until you get p > .05 in Shapiro-Wilk! Choose based on data type, not desired outcome.
4. When Non-Parametric is Easier
If transformation makes interpretation too complex, just use Mann-Whitney or Kruskal-Wallis.
Step 1: Check your diagnostic plots
Step 2: Consider your data type
Step 3: Apply transformation and re-check
Step 4: Report clearly
Scenario: You're analyzing time spent studying (in minutes) for 40 students:
Question 4A: Based on this information, what transformation would you try first? Why?
Question 4B: After applying log transformation, you get:
Write how you would report this in a Methods section:
Question 4C: Your analysis yields a mean of 4.20 on the log scale (SE = 0.15). How would you report this in original minutes?
Hint: exp(4.20) = 66.7 minutes
Mistake 1: Transforming without checking if it helped
โ "I log-transformed the data" (but didn't verify it worked)
โ "Log transformation improved normality (W = 0.89 โ 0.96, p = 0.002 โ 0.22)"
Mistake 2: Trying transformations until p > .05
โ P-hacking: Testing 5 transformations to find one that works
โ Choose based on data characteristics, not desired p-value
Mistake 3: Forgetting about zeros/negatives
โ log(0) = error!
โ Add constant: log(x + 1) if you have zeros
Mistake 4: Not considering interpretability
โ Running complex analysis on transformed data without explaining results
โ Back-transform key results for interpretation
Mistake 5: Transforming categorical data
โ log(Likert scale 1-5)
โ Use non-parametric tests for ordinal data
โ Transformations change the scale to make data more normal
Log, square root, and square transformations can fix many skewness problems.
โ Choose based on data type and skew direction
โ Always verify the transformation worked
Re-check histograms, Q-Q plots, and Shapiro-Wilk after transforming.
โ Report clearly and consider interpretation
Tell readers what you did and back-transform results when appropriate.
โ When in doubt, use non-parametric
If transformation is too complex or doesn't help, non-parametric tests are a great alternative!
In Module 5, you'll learn:
Grading: Credit/no-credit, not scored for correctness — but credit requires a genuine attempt; blank or clearly-unattempted answers earn no credit. Work through it with your partner and say what you actually think; a wrong idea you reasoned your way to is worth more here than a right one you copied.
module4_lastname1_lastname2.pdf๐ You've mastered data transformations! ๐
Next: Module 5 will cover non-parametric alternatives when transformation isn't the answer!