Shapiro-Wilk test
Goodness of fit and normality · reference distribution: W (tabulated)
When to use it
Check whether a sample comes from a normal distribution; it is the most powerful normality test for small and medium samples.
Null hypothesis
The data come from a normal distribution.
Assumptions
- Independent observations
- With very large n, it rejects irrelevant departures: look at the Q-Q plot too
Test statistic
W = \dfrac{\left(\sum a_i\, x_{(i)}\right)^2}{\sum (x_i - \bar{x})^2}How to report it
W = 0.96, p = .31
In R and Python
R
shapiro.test(x)
Python
stats.shapiro(x)
In Python, stats is scipy.stats and np is numpy.
Where it sits in the catalog
Goodness of fit and normality. Goodness of fit: do the data follow the expected distribution? Normality tests are the most common case and check an assumption of parametric tests.
In the decision tree
- What do you want to do? Check an assumption or the distribution of the data
- What do you want to check? Whether the data are normal
- How large is the sample? Small or medium
It also appears alongside other tests:
- To check an assumption before One-sample t, Two-sample t, Paired t, One-way ANOVA, Two-way ANOVA.