Shapiro-Wilk Normality Test

Statistics
Introduced by
S. S. Shapiro & M. B. Wilk
Year
1965
Type
Normality (goodness-of-fit) test

What does it do?

The Shapiro-Wilk test is a hypothesis test of whether a continuous variable was drawn from a normal distribution.

Samuel Shapiro and Martin Wilk introduced it in 1965, framing it as an analysis of variance test for normality on complete samples. Its W statistic measures how closely the ordered sample agrees with the pattern expected under normality; W near 1 indicates close agreement and small values indicate departure from normality.

The intuition behind the method

Many classical procedures, such as the t-test or ANOVA, assume approximately normal data, so before trusting them you need a way to check that assumption. The Shapiro-Wilk test is related to a normal probability plot: it measures the correlation between the ordered sample values and the values expected under normality. If the normal probability plot is nearly a straight line, W is close to 1, and a small W (small p-value) is evidence of non-normality.

History

Samuel S. Shapiro and Martin B. Wilk introduced the W statistic in a 1965 Biometrika paper, framed as an analysis of variance test for normality on complete samples. For testing normality it is generally regarded as more powerful than general goodness-of-fit procedures such as the Kolmogorov-Smirnov test.

When to use it

Use it to check the normality of a single continuous variable, most often as an assumption check before a parametric procedure such as a t-test or ANOVA. It can also be applied to the residuals of a regression or ANOVA model, where residual normality is the assumption being examined. Do not use it for discrete or categorical variables. Software implementations restrict the sample size (for example, R's shapiro.test accepts roughly 3 to 5000 observations); this restriction comes from the implementation and its p-value approximation, not from the 1965 paper, so check the documentation of your software. With very few observations the test has little power to detect non-normality. With very large samples it can flag trivial deviations, so judge the result alongside a histogram or Q-Q plot and the size of the deviation.

Limitations and considerations

  • It is designed for a single continuous variable and does not apply to discrete or categorical data.
  • Its sensitivity grows with sample size, so at large n it can reject normality for deviations too small to matter for a t-test or ANOVA.
  • A rejection indicates that the sample departs from normality but not how; W gives no information about the direction or form of the departure.
  • With very small samples its power to detect non-normality is low, and software implementations restrict the usable sample-size range.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • The statistic is built from the ordered sample values, weighted by coefficients derived from expected normal order statistics, so it responds to the overall shape of the sample rather than only to its spread.
  • W is bounded between 0 and 1, so the degree of agreement with normality can be read directly from the statistic.
  • It has a single statistic and one decision rule, with no user-chosen tuning parameters.

Applications

  • Checking the normality assumption of a continuous outcome before running a t-test or ANOVA.
  • Validating that model residuals are approximately normal in regression diagnostics.
  • Screening measurement data in quality and laboratory studies for distributional assumptions.
  • Deciding whether to use a parametric test or switch to a nonparametric alternative.

How it works

How it works

1

The null hypothesis states that the sample comes from a normally distributed population; the alternative states that it does not. A non-significant result is taken as no evidence against normality, not as proof of it.

Formula
H_0:\ \text{the sample is drawn from a normal distribution} \quad H_1:\ \text{it is not normally distributed}
2

The W statistic is the squared weighted combination of the ordered sample values divided by the total sum of squared deviations from the mean. The coefficients a_i are normalized weights computed from the expected values of normal order statistics together with their covariance matrix. W is closely related to the squared correlation between the sample order statistics and the expected normal order statistics. W lies between 0 and 1, with values near 1 indicating close agreement with normality and small values leading to rejection.

Formula
W = \dfrac{\left(\sum_{i=1}^{n} a_i x_{(i)}\right)^2}{\sum_{i=1}^{n}\left(x_i - \bar{x}\right)^2}, \quad (a_1,\dots,a_n) = \dfrac{m^{\top}V^{-1}}{\left(m^{\top}V^{-1}V^{-1}m\right)^{1/2}}
3

The W statistic is converted to a p-value; this conversion relies on approximations developed after the 1965 paper and is performed by software. If the p-value falls below the conventional significance level of 0.05, the null hypothesis is rejected and the data show a significant departure from normality. Otherwise normality is not rejected, although this does not prove that the data are normal.

Formula
\text{reject } H_0 \text{ if } p < 0.05

Common pitfalls

  • Reading a significant result as proof that parametric tests are invalid, without considering sample size and a plot of the data.
  • Relying on the test alone for very large samples, where negligible deviations are flagged as significant.
  • Reading a non-significant result as proof that the sample is normal; the null hypothesis is never confirmed by the test.
  • Using software outside its supported sample-size range without checking how the p-value is computed.

Frequently asked questions

Should I prefer Shapiro-Wilk or Kolmogorov-Smirnov?

For testing normality, Shapiro-Wilk is more powerful than the general-purpose Kolmogorov-Smirnov test, so it is usually the better choice. With very large samples, any normality test may flag trivial deviations, so base the decision on a Q-Q plot and the size of the deviation rather than simply switching tests.

What does a non-significant result mean?

A p-value above 0.05 means there is no significant evidence against normality, so you may proceed with methods that assume normality. It does not prove the data are exactly normal, since failure to reject the null is not positive proof.

How many observations do I need?

Implementations typically require at least 3 observations (for example R's shapiro.test), and an upper limit of about 5000 in that software. With very few points the test has little power to detect non-normality, so a non-significant result should be read cautiously and together with a plot.

My data fail the test. What should I do?

Consider the sample size and inspect a histogram or Q-Q plot before deciding. If non-normality is genuine, you can transform the variable or switch to a nonparametric method instead of forcing a parametric test.

Related methods

Sources

  1. Shapiro, S. S. & Wilk, M. B. (1965). An analysis of variance test for normality (complete samples). Biometrika, 52(3-4), 591–611.

    Open DOI reference