11  Checking Normality in R

NoteWhat you’ll be able to do

By the end of this chapter you will be able to:

  1. Use histograms and Q-Q plots as your first normality check.
  2. Run and interpret Shapiro-Wilk — including its large-sample caveat.
  3. Apply the right checking workflow for each test type (for paired designs: check the differences).
  4. Work through the 30-second decision workflow: proceed, transform, or go non-parametric.

The previous chapter explained why we check normality and what we check. This chapter shows you the actual R commands. Once you have this workflow internalized, it should fit into any analysis script in well under a minute.

The chapter is structured around a single decision tree: “did I fit a model with lm() or aov()?” The answer determines what you check.

11.1 The decision tree

Did I fit a model with lm() or aov()?
│
├── YES → Check residuals: residuals(model)
│
└── NO  → Check the relevant data:
          │
          ├── One-sample t-test    → The variable itself
          ├── Independent t-test   → Each group separately
          ├── Paired t-test        → The difference scores
          └── Correlation          → Both variables

The t-tests are models too (Chapter 10), but their residuals are just each score minus its group mean, so checking the data directly is the same check.

The rest of the chapter is the R code for each branch of that tree.

11.2 Visual checks — your first stop

For every check below, do the visual inspection first. The visual is more informative than any single number, especially with large samples.

11.2.1 Basic histogram

hist(what_to_check,
     main = "Distribution",
     col = "lightblue",
     breaks = 15)

breaks controls the bin count. Try a few values — 10, 15, 30. The shape of a distribution can look very different depending on bin count, and a single histogram can mislead.

11.2.2 Histogram with normal curve overlay

hist(what_to_check, freq = FALSE, col = "lightblue")
curve(dnorm(x, mean = mean(what_to_check),
                sd = sd(what_to_check)),
      add = TRUE, col = "red", lwd = 2)

freq = FALSE puts density (not counts) on the y-axis. curve(dnorm(...)) overlays a normal density curve with the same mean and SD as your data. If your histogram tracks the red curve, you’re close to normal.

11.2.3 Q-Q plot

The Q-Q plot is the single most useful normality diagnostic.

qqnorm(what_to_check)
qqline(what_to_check, col = "red")

How to read it:

  • Points hugging the line → roughly normal.
  • An S-shape → tails are heavier or lighter than normal (kurtosis problem).
  • A curve (arched up or down) → skewed (one tail much longer than the other).
  • A handful of points far off the line at one end → outliers.

Four Q-Q plots. Top left: points closely follow the diagonal reference line, labeled normal. Top right: points curve below the line at the low end and above it at the high end, an S-shape, labeled heavier tails than normal. Bottom left: points arc above the reference line at both ends in the same direction, labeled right-skewed. Bottom right: most points hug the line but a handful break sharply away above it at the high end, labeled outliers.

All four patterns side by side: normal (points hug the line), heavier tails than normal (S-shape), right skew (a smooth curve arcing away from the line in one direction), and a handful of planted outliers breaking off at the high end.

Q-Q plot with points following the diagonal reference line closely.

A Q-Q plot you can proceed with: points follow the diagonal closely, with only minor drift at the extremes — normal and expected.

Q-Q plot of right-skewed data with points curving away from the diagonal at the upper end.

A Q-Q plot signaling right skew: points curve upward away from the line at the right end. This is the pattern that calls for a transformation (Chapter 12) or a non-parametric test (Chapter 13). More annotated examples are in the workflow guide (Appendix D).

11.2.4 Multiple plots at once

When you want a histogram and Q-Q plot side by side:

par(mfrow = c(1, 2))                                # 1 row × 2 columns
hist(what_to_check, col = "lightblue", main = "Histogram")
qqnorm(what_to_check, main = "Q-Q Plot")
qqline(what_to_check, col = "red")
par(mfrow = c(1, 1))                                # reset

par(mfrow = c(rows, cols)) arranges multiple plots in a grid; always reset to c(1, 1) afterward.

11.3 Statistical tests for normality

11.3.1 Shapiro-Wilk (the workhorse)

shapiro.test(what_to_check)

Interpretation:

  • \(p > 0.05\) → cannot reject normality (data are consistent with normal — note the careful phrasing).
  • \(p < 0.05\) → reject normality (data appear non-normal).

Caveat for large samples: Shapiro-Wilk becomes oversensitive when \(n\) is large. With \(n = 500\), almost any real-world dataset will show \(p < 0.05\), even if the deviation from normality is meaningless in practice. For \(n > 50\) or so, lean on the visual rather than the test.

Left panel: histogram of 500 simulated values, appearing close to a normal bell curve with only mild right skew noted in the title. Right panel: text output showing shapiro.test results with a significant p-value, alongside a note explaining that this is significant despite the mild skew and roughly symmetric appearance, illustrating large-sample oversensitivity.

A simulated sample of n = 500 with mild right skew. The histogram looks close to normal — the skew is well under the 0.5 rule-of-thumb threshold — but shapiro.test() still returns a significant result. This is the large-sample oversensitivity the caveat above describes: significance here reflects sample size, not a practically important departure from normality.

11.3.2 Anderson-Darling and Kolmogorov-Smirnov

For a second opinion (they share Shapiro-Wilk’s large-sample oversensitivity):

library(nortest)
ad.test(what_to_check)      # Anderson-Darling
lillie.test(what_to_check)  # Kolmogorov-Smirnov (Lilliefors correction)

These have the same interpretation as Shapiro-Wilk.

11.3.3 Descriptive indicators

skewness and kurtosis numbers give you a second angle:

library(e1071)
skewness(what_to_check)
kurtosis(what_to_check)

Rules of thumb (very rough):

  • \(|\text{skew}| < 0.5\) → symmetric.
  • Excess kurtosis between \(-1\) and \(+1\) → acceptable tails. Note: e1071::kurtosis() reports excess kurtosis, so a normal distribution gives \(\approx 0\), not 3. (If you compute raw kurtosis by hand instead, the equivalent range is 2 to 4, with normal = 3.)

These are guidelines, not laws. Use them alongside the visual.

11.4 Workflow by test type

Here is the code template for each branch of the decision tree.

11.4.1 One-sample t-test

What to check: the variable itself.

# Quick check
shapiro.test(data$variable)
hist(data$variable)

# If normal
t.test(data$variable, mu = test_value)

# If not normal (rank-based; assumes rough symmetry, see Chapter 13)
wilcox.test(data$variable, mu = test_value)

11.4.2 Independent-samples t-test

What to check: each group’s data separately.

# Shapiro-Wilk per group, in one call
tapply(data$outcome, data$group, shapiro.test)

# Visual check
library(ggplot2)
ggplot(data, aes(x = outcome)) +
  geom_histogram() +
  facet_wrap(~ group)

# If both groups look normal
t.test(outcome ~ group, data = data)

# If not
wilcox.test(outcome ~ group, data = data)

tapply() applies a function to a numeric variable broken up by a grouping variable — here, it runs shapiro.test() separately for each level of group.

11.4.3 Paired t-test

What to check: the differences, not the two columns separately.

# Create the differences
diffs <- data$post - data$pre

# Quick check
shapiro.test(diffs)
hist(diffs)

# If normal
t.test(data$post, data$pre, paired = TRUE)

# If not
wilcox.test(data$post, data$pre, paired = TRUE)
WarningA common mistake for paired tests

For paired t-tests, you check the difference scores, not each column separately. The two columns can each be skewed and the differences can still be normal (or vice versa). The paired t-test works on the differences, so that’s what the assumption is about.

11.4.4 One-way ANOVA

What to check: model residuals, not raw data.

# Fit the model
model <- aov(outcome ~ group, data = data)

# Quick check
shapiro.test(residuals(model))
plot(model, which = 2)          # Q-Q plot of residuals

# If normal
summary(model)

# If not normal
kruskal.test(outcome ~ group, data = data)

plot(model, which = 2) produces a Q-Q plot specifically for the model’s residuals — convenient.

11.4.5 Two-way ANOVA

Same logic, with an interaction term in the model:

model <- aov(outcome ~ factorA * factorB, data = data)
shapiro.test(residuals(model))
plot(model, which = 2)

# If normal
summary(model)

# If not normal
# Consider transformation, or report with caveats

There is no clean non-parametric equivalent for two-way ANOVA: the rank-based tests in Chapter 13 handle one factor at a time. If the residuals are clearly non-normal, try a transformation (Chapter 12); otherwise run the ANOVA and report the departure as a limitation.

11.4.6 Linear regression

What to check: residuals. The full plot(model) call gives you four diagnostics at once.

model <- lm(Y ~ X1 + X2, data = data)

# All four diagnostic plots
par(mfrow = c(2, 2))
plot(model)
par(mfrow = c(1, 1))

# Or just the normality check
shapiro.test(residuals(model))

The four plots are: residuals vs. fitted, normal Q-Q, scale-location, and residuals vs. leverage. They’re covered in detail in Chapter 25.

11.4.7 Correlation

What to check: both variables (when you want a p-value for the correlation).

shapiro.test(data$var1)
shapiro.test(data$var2)

par(mfrow = c(1, 2))
hist(data$var1); hist(data$var2)
par(mfrow = c(1, 1))

# If both normal
cor.test(data$var1, data$var2, method = "pearson")

# If not
cor.test(data$var1, data$var2, method = "spearman")

11.5 The 30-second workflow

Once you’ve done a few analyses, the workflow above collapses to this:

# 1. Fit the model (if applicable)
model <- lm(y ~ x, data = data)   # or aov(), etc.

# 2. Check residuals (or your variable, if no model)
par(mfrow = c(1, 2))
hist(residuals(model))
qqnorm(residuals(model)); qqline(residuals(model))
par(mfrow = c(1, 1))

# 3. Decide
#    Looks OK?         → Proceed with parametric test
#    Clearly violated? → Transform or go non-parametric
#    Unsure?           → Check sample size; if n > 30, probably OK

That’s the whole assumption check. Three steps, half a minute, and you have a defensible decision.

11.6 Common mistakes — quick fixes

Instead of… Do this
Checking raw DV for ANOVA shapiro.test(residuals(model))
Checking predictors in regression Only check residuals — predictors never need to be normal
Panicking about \(p = 0.048\) Check visually; consider sample size
Testing with \(n > 50\) Just use visual inspection — Shapiro is oversensitive
Checking pre and post separately for a paired test Check the differences (post − pre)
Running Shapiro on each small group for ANOVA Per-group checks are valid (each group’s deviations from its mean are its residuals), but each test has little power when groups are small. shapiro.test(residuals(model)) pools all groups into one larger check
One pooled histogram of the outcome for a group comparison Plot each group separately (facet_wrap(~ group)) or check residuals — a group difference alone can make a pooled histogram look lopsided

11.7 A complete worked example

Comparing scores between two groups, the typical homework scenario:

# Step 1: Look at the data
str(data)
summary(data)

# Step 2: Check normality per group
tapply(data$score, data$group, shapiro.test)

# Step 3: Visualize — each group separately, not one pooled histogram
boxplot(score ~ group, data = data, main = "Boxplot")

library(ggplot2)
ggplot(data, aes(x = score)) +
  geom_histogram(bins = 15) +
  facet_wrap(~ group)

# Step 4: Decide and run
# Both groups normal-ish, no severe outliers, n = 50 per group → t-test fine
t.test(score ~ group, data = data)

11.8 Remember

  • Models → check residuals. No model → check the data.
  • Visual > statistical tests, especially with large \(n\).
  • \(n > 30\) per group buys you meaningful robustness via the CLT.
  • Decide which test you’ll report before you run it. Running both and reporting whichever comes out significant is a quiet form of p-hacking. If you run both as a check and they disagree, report both and say why: they test different things (means vs. whole distributions), so a disagreement doesn’t automatically mean the assumption violation was to blame.

In the next chapter, we look at what to do when the visual or test clearly says “this isn’t normal”: data transformations.


TipChapter Summary

Core idea: No single check tells you whether normality holds. Use three together: histogram (shape), Q-Q plot (tail behavior), and Shapiro-Wilk (formal test). Then use judgment, not a mechanical rule.

You should understand:

  • What a Q-Q plot is showing and how to read systematic curves vs. random scatter
  • Why Shapiro-Wilk is unreliable at very small n (underpowered) and very large n (oversensitive)
  • The difference between checking normality for a t-test (per group), a paired test (differences), and ANOVA/regression (residuals after fitting)

You should be able to do in R:

  • Histogram: hist(x)
  • Q-Q plot: qqnorm(x); qqline(x)
  • Shapiro-Wilk: shapiro.test(x)
  • Per-group check: tapply(data$score, data$group, shapiro.test)
  • Residuals check: shapiro.test(residuals(model))

Plain-language check: You run Shapiro-Wilk with n = 250 and get p = .04. Your histogram looks symmetric with no obvious skew. What do you conclude, and why?

The one mistake to avoid: Treating Shapiro-Wilk p > .05 as a green light and p < .05 as a red light, regardless of sample size. The visual checks matter — especially at extreme sample sizes where Shapiro-Wilk is least reliable.

Practice: You are running a paired t-test comparing pre- and post-training scores. Write the three lines of R code you would run to check the normality assumption correctly.

Key terms from this chapter are defined in the Glossary.

NoteNormality Practice
TipWork through it with a partner

Two interactive modules cover this chapter. Both are worked in R alongside the page, in pairs, and printed to PDF to hand in.

Modules open in a new tab.