Shapiro–Wilk test
Intermediate
What you need first. Nothing else on this path comes first. This page is part of Data analysis.
In data analysis, the Shapiro–Wilk test is a test of whether a complete sample could have come from some normal distribution, based on the match between the ordered values and normal order statistics. It is a test of the composite hypothesis that a complete sample comes from some normal distribution. Location and scale are not specified in advance. A small value of the statistic is evidence against that hypothesis, and a large value is not evidence that the hypothesis is true.
Shapiro–Wilk test
| Fact | Value |
|---|---|
| Topic | Data analysis |
| Listed on | Data analysis |
Motivating example
Eight reaction times, in seconds, are Seven of them sit between and . The eighth is more than twice the largest of those seven. A normal probability plot asks whether the ordered sample tracks the quantiles of a normal curve. The Shapiro–Wilk statistic turns that question into one number, , small when the order statistics fail to line up with the expected normal order statistics. On these eight numbers falls below the point of its null distribution. The same eight numbers, after a natural logarithm, give a above the point. The calculation is the worked example. The second result does not prove that the logarithms are normal.
A scaled slope against normal order statistics
Let be the ordered sample, and write for the expected value of the th order statistic in a standard normal sample of size . Let be the covariance matrix of those order statistics. The best linear unbiased estimate of the slope in the regression of the on the uses both and . Write The coefficient vector is the normalised best linear unbiased vector, so is proportional to that slope estimate. It is not the slope itself. The Shapiro–Wilk statistic is The coefficients are determined by and by . They are not the ordinary least-squares coefficients from a plot of against alone, because that plot’s residuals are correlated. For a symmetric reference distribution the coefficients are antisymmetric, , and the middle coefficient is zero when is odd.[1] [2]
If the sample really is normal, the numerator and the denominator are estimating the same multiple of the variance, and tends to sit near its upper bound of . If the sample is not normal, the two pieces are not estimating the same thing, and the null mean of is shifted to the left. Small values of are the evidence against normality. The distribution of , for a sample from a normal distribution, depends only on . That is the content of scale and origin invariance. Multiplying every observation by multiplies by and therefore the numerator by , and it multiplies the denominator by . Adding a constant leaves unchanged, because the coefficients sum to zero, and it leaves the sum of squared deviations unchanged.[1]
For even the numerator can be computed from the upper half of the coefficients and the gaps between opposite order statistics, The coefficients for are tabulated. They are an input to the statistic, not a quantity to be re-derived from in the course of a single test.[1]
What a small -value settles, and what a large one does not
The test rejects for small . A -value is the probability, under normality, of a statistic at most as large as the one observed. A small -value is evidence that this sample’s order statistics are a poor match to the normal pattern. It is not a measure of how badly a later test or analysis of variance will behave, and it is not a measure of the scientific size of the departure. The introduction of the procedure makes the modest claim: knowing that a normality assumption is wrong should temper the use of methods that were derived under it, and should send the analyst back to the plot, to a transformation, or to a procedure that does not need the assumption.[1]
A large -value means that did not fall in the rejection region for that . Many non-normal distributions produce samples whose sits above a or point, especially when is small. Failure to reject is the statement the test is able to make. It is not a demonstration that the distribution is normal. In the paper’s own numerical illustration, a above the point is treated as compatible with a normal sample of the remaining effects, and the plot is still part of the argument. The statistic was proposed as a supplement to the normal probability plot, not as a replacement for it.[1]
The null distribution moves with . The lower point of is at , at and at . A numerical value such as is above the point at and below it at . The same is therefore not the same significance statement at two sample sizes. At the test is already sensitive to strong skewness: in the published sampling comparison, a test has empirical power against a chi-squared distribution on one degree of freedom. Sensitivity at one sample size is not a power curve, and the critical-value table is not one either. What the table does show is that a larger requires closer to before the sample is passed at a fixed level.[1]
The normal model in a one-way layout is a statement about the errors. The observations follow with the independent and . The raw responses are those errors plus the group means. A Shapiro–Wilk test of the pooled responses confuses a difference of means with a failure of normality.[3]
Normal Q–Q plots of within-group fitted residuals can help diagnose departures from the error model, but do not establish normality. The fitted residuals are not generally an independent sample: subtracting each fitted group mean constrains the residuals in that group to sum to zero. With two groups of size two, the residuals in group are exactly , where , even when the errors are independent and normal. The ordinary Shapiro–Wilk -value calibration therefore does not generally apply to pooled fitted residuals; a formal test requires calibration that accounts for the fitted model.
Residuals, software, and the plot
The ordinary Shapiro–Wilk -value is calibrated under a null model of independent, identically distributed normal observations. For a single group of independent, identically distributed observations, subtracting its sample mean leaves unchanged by location invariance, so centring alone does not alter the test. This invariance does not justify applying the ordinary calibration to residuals pooled after fitting separate group means.
The function shapiro.test accepts a numeric vector of length to after missing values are removed. It returns and an approximate -value. For that -value is exact; between and , and again from upward, the reference distribution is an approximation.[4] The documentation of that returned -value says the approximation is adequate for -values below , and it attributes the statement to Royston’s 1995 paper.[4] A result near , such as the logged times in the worked example below, is on the side of the approximation where that report does not claim accuracy, which is another reason to read it together with the probability plot rather than as a sharp probability.
The coefficients themselves need not be recomputed. For they are the tabulated values used in the worked example below. For larger the original difficulty was precisely that the coefficients and the percentage points become awkward to tabulate. Software is the practical source of in that range. The hand calculation in that worked example is a check that the software statistic is the statistic, not a second definition.[1]
The same eight times, raw and logged
The assumptions for the calculation are that the eight times are a complete sample, with no missing values, and that the question is the composite normal hypothesis. The coefficients for , reading down the tabulated column, are and . The ordered sample is already . The gaps that enter are Hence The sample mean is , and the sum of squared deviations from it is . Therefore The lower point at is and the lower point is . The observed is below the point, so the table rejects normality at .[1]
The normal probability plot makes the same departure visible without producing . One plotting position for the th ordered value is . For the standard normal quantiles of those eight positions run from to . The step from to is , and the step from to is . The corresponding quantile steps are and . The data step is times the one before it; the quantile step is times the one before it. That is the gap has charged at the largest coefficient, .[3]
shapiro.test on these eight numbers returns and an approximate -value . The statistic matches the four-decimal table to three significant figures. The -value is not an exact tail probability from Table 6. The returned probability is an approximation except at , where it is exact; separate approximations are used for and for . Both the table and the software agree that the result is below the point.[4]
Now replace each time by its natural logarithm. The ordered logs are , to three decimals. The same four coefficients give and a sum of squared deviations , so . At the lower point is and the lower point is . The value lies above the point, so the test and the test both fail to reject. shapiro.test returns and , the same conclusion.[1] [4]
The transformation changed the conclusion. It did not certify the log-times as normal. A sample of size whose is has simply failed to reach the rejection region. The plot of the logs against the same normal quantiles is straighter than the raw plot, and that is a description of these eight points. It is not a proof of the distribution.
Your turn. A sample of size has , and a sample of size has the same . The lower points are at and at . What does the test do in each case?
The test rejects for small . At , , so the test does not reject. At , , so the test rejects. The number is not a significance statement until it is compared with the critical value for that sample size.
A large probability is not a proof of normality
The logged sample is the counterexample to the most common reading. Its is about , its software -value is about , and the point at is . Nothing in that comparison says the logarithms came from a normal distribution. It says a normal sample of size often produces a this far from . The raw sample, with and , is the case the test was built to flag. Treating the two -values as “not normal” and “normal” uses the second one as a proof it cannot be.
A related confusion is to read a very small -value in a large sample as a large departure. The power against a fixed alternative grows with . Against a distribution on degrees of freedom, a symmetric law with kurtosis , a Shapiro–Wilk test rejected about of samples of size and about of samples of size . Against asymmetric alternatives the same test had reached good power once was at least . The comparison’s conclusion is that this power rises with the sample size, while remaining low for samples of size and below. A significant result in a large sample can also come from a small deviation from normality, and that small deviation need not affect a parametric procedure that uses the same observations. Those are different questions, and the second one is not a function of alone.[5] [6]
Complete samples and a null that depends on
The derivation assumes a complete sample: every order statistic from to is present. A sample with missing values, or a censored sample, is not this statistic. The null is the whole normal family, not a normal distribution with a stated mean and variance. That is why scale and origin invariance matter, and why does not answer a simple goodness-of-fit question in which and were given before the data.[1]
The percentage points in the table run to and are themselves based on sampling and a curve fit for the larger sizes in that range. Quoting a point from that table is not the same act as quoting an exact binomial tail. The -value from shapiro.test adds a further approximation except at . For the eight raw times the distinction is harmless, because is below the tabulated point and the software -value is . For a close to a critical value, the table and the software probability can be reported side by side rather than collapsed into one number.[1] [4]
The normal plot, the transformation, and the t test
A normal quantile plot is the picture summarises. The normal distribution is the hypothesis under test. Transformations of data are one response when the raw sample is rejected and the scientific scale can change, as with the logarithms above. The one-sample test and the two-sample test are procedures whose derivations use normality; a Q–Q plot of fitted residuals can help diagnose departures from the error model, but does not establish normality or replace the inference. An ordinary Shapiro–Wilk -value on pooled fitted residuals does not generally have the calibration of a test on an independent, identically distributed normal sample.
Check yourself
1. Every reaction time in the worked example is multiplied by . What happens to ?
Each order statistic is multiplied by , so each gap in is multiplied by and is multiplied by . The sum of squared deviations is multiplied by . The ratio over that sum is unchanged. The same conclusion is the scale invariance of .
2. At the lower point of is , and a sample of that size has . Does the test reject, and does the result establish normality?
The test rejects for small . Here , so the test does not reject. Failing to reject means the statistic missed the rejection region. It does not establish that the sample came from a normal distribution.
3. A one-way layout has different group means, and a Shapiro–Wilk test of all the raw responses pooled together gives a small . Which series is the normality assumption of that layout about?
The errors. Each observation is a group mean plus an error, so the pooled raw responses mix those means into the shape. Normal Q–Q plots of within-group fitted residuals can help diagnose departures from the error model, but do not establish normality. Fitting the group means makes the residuals dependent, so the ordinary Shapiro–Wilk -value calibration does not generally apply to the pooled residuals.
The 1965 analysis-of-variance form
S. S. Shapiro and M. B. Wilk introduced in 1965 as a summary of the normal probability plot. The slope of the regression of the order statistics on their normal expected values estimates the scale if the plot is linear. Dividing the square of that slope by the ordinary sum of squares produces a scale-free statistic for the composite null. The coefficients are the normalised best linear unbiased coefficients, which bring in the covariances of the order statistics as well as their means. The null percentage points were obtained by sampling, and a comparison at sample size found the test sensitive across a wide range of alternatives, particularly skewness and long tails.[1]
The same statistic is stated with its origin, the formula, and the fact that the coefficients come from the means, variances and covariances of the normal order statistics. The implementation in shapiro.test follows Royston’s later algorithm: the returned -value is exact only for , and approximations are used for and for .[2] [4]
See also
Line chart · Apriori algorithm · Asymptotic analysis · Average treatment effect · Base rate · Bayesian inference · Bayesian model · Bayesian probability
References
- ^ a b c d e f g h i j k l a. (pp. 592–593, 603) b. (pp. 592–593, Lemma 1 and the bound ) c. (p. 603 and Table 5) d. (p. 591) e. (pp. 607, 610) f. (Table 6, p. 605; Table 7, p. 608; p. 609) g. (p. 610) h. (Tables 5 and 6, pp. 603–605) i. (Table 6, p. 605) j. (pp. 591–593) k. (Table 6, note on the approximation) l. (pp. 591–593, 608, 610) Shapiro, S. S. & Wilk, M. B. (1965). An Analysis of Variance Test for Normality (Complete Samples). Biometrika, 52(3/4), 591-611. https://doi.org/10.1093/biomet/52.3-4.591
- ^ a b a. (§7.2.1.3) b. (§7.2.1.3) NIST/SEMATECH (2002). NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.1.3: Shapiro-Wilk Normality Test. National Institute of Standards and Technology. https://www.itl.nist.gov/div898/handbook/prc/section2/prc213.htm
- ^ a b a. (p. 399) b. (p. 382) Dodge, Yadolah (2008). The Concise Encyclopedia of Statistics. Springer. https://doi.org/10.1007/978-0-387-32833-1
- ^ a b c d e f a. (Usage, Arguments, Value and Source) b. (Value) c. (Value and Source) d. (Value) e. (Source) f. (Source and References) R Core Team (2026). Shapiro-Wilk Normality Test (R-devel documentation for shapiro.test). R Foundation for Statistical Computing. https://stat.ethz.ch/R-manual/R-devel/library/stats/html/shapiro.test.html
- ^ (Table 1, p. 28; p. 29; Table 2, p. 30; p. 32) Razali, Nornadiah Mohd & Wah, Yap Bee (2011). Power comparisons of Shapiro-Wilk, Kolmogorov-Smirnov, Lilliefors and Anderson-Darling tests. Journal of Statistical Modeling and Analytics, 2(1), 21–33. http://www.de.ufpb.br/~ulisses/disciplinas/normality_tests_comparison.pdf
- ^ (§3, Normality Tests) Ghasemi, Asghar & Zahediasl, Saleh (2012). Normality Tests for Statistical Analysis: A Guide for Non-Statisticians. International Journal of Endocrinology and Metabolism, 10(2), 486–489. https://doi.org/10.5812/ijem.3505
Cite this page
StatWiki (2026). "Shapiro–Wilk test." StatWiki. Last updated 2 December 2026. https://www.statwiki.io/articles/shapiro-wilk-test.html
@misc{statwiki_shapiro_wilk_test,
author = {{StatWiki}},
title = {{Shapiro–Wilk test}},
year = {2026},
url = {https://www.statwiki.io/articles/shapiro-wilk-test.html},
urldate = {2026-12-02},
note = {StatWiki, last updated 2 December 2026}
}