Shapiro–Wilk test

The Shapiro–Wilk test is a test of normality. It was published in 1965 by Samuel Sanford Shapiro and Martin Wilk.

Theory
The Shapiro–Wilk test tests the null hypothesis that a sample x1, ..., xn came from a normally distributed population. The test statistic is


 * $$W = {\left(\sum_{i=1}^n a_i x_{(i)}\right)^2 \over \sum_{i=1}^n (x_i-\overline{x})^2},$$

where


 * $$x_{(i)}$$ with parentheses enclosing the subscript index i is the ith order statistic, i.e., the ith-smallest number in the sample (not to be confused with $$x_i$$).
 * $$\overline{x} = \left( x_1 + \cdots + x_n \right) / n$$ is the sample mean.

The coefficients $$a_i$$ are given by:
 * $$(a_1,\dots,a_n) = {m^{\mathsf{T}} V^{-1} \over C},$$

where C is a vector norm:
 * $$C = \| V^{-1} m \| = (m^{\mathsf{T}} V^{-1}V^{-1}m)^{1/2}$$

and the vector m,
 * $$m = (m_1,\dots,m_n)^{\mathsf{T}}\,$$

is made of the expected values of the order statistics of independent and identically distributed random variables sampled from the standard normal distribution; finally, $$V$$ is the covariance matrix of those normal order statistics.

There is no name for the distribution of $$W$$. The cutoff values for the statistics are calculated through Monte Carlo simulations.

Interpretation
The null-hypothesis of this test is that the population is normally distributed. Thus, if the p value is less than the chosen alpha level, then the null hypothesis is rejected and there is evidence that the data tested are not normally distributed. On the other hand, if the p value is greater than the chosen alpha level, then the null hypothesis (that the data came from a normally distributed population) can not be rejected (e.g., for an alpha level of .05, a data set with a p value of less than .05 rejects the null hypothesis that the data are from a normally distributed population – consequently, a data set with a p value more than the .05 alpha value fails to reject the null hypothesis that the data is from a normally distributed population).

Like most statistical significance tests, if the sample size is sufficiently large this test may detect even trivial departures from the null hypothesis (i.e., although there may be some statistically significant effect, it may be too small to be of any practical significance); thus, additional investigation of the effect size is typically advisable, e.g., a Q–Q plot in this case.

Power analysis
Monte Carlo simulation has found that Shapiro–Wilk has the best power for a given significance, followed closely by Anderson–Darling when comparing the Shapiro–Wilk, Kolmogorov–Smirnov, and Lilliefors.

Approximation
Royston proposed an alternative method of calculating the coefficients vector by providing an algorithm for calculating values that extended the sample size from 50 to 2,000. This technique is used in several software packages including GraphPad Prism, Stata,  SPSS and SAS. Rahman and Govidarajulu extended the sample size further up to 5,000.