Sample size

Sample size calculator for the Shapiro–Wilk test

Estimate the number of observations needed to detect deviations from normality with the Shapiro–Wilk test using the Jarque–Bera approximation.

Estimate the number of observations needed for the Shapiro–Wilk test to detect deviations from normality with the target power, using the Jarque–Bera approximation.

Calculator

Enter the skewness and excess kurtosis of the alternative distribution, the significance level and the desired power.

Result pending…
Notes: (a) This calculation is a conservative lower bound: the Jarque–Bera approximation tends to overestimate the required n because the Shapiro–Wilk test is generally more powerful. (b) The Shapiro–Wilk test is valid for 3 ≤ n ≤ 5000; n ≥ 8 is recommended for reasonable power.

Explanation

The Shapiro–Wilk test contrasts the null hypothesis that a sample comes from a normal distribution. Its power depends on how much the real (alternative) distribution differs from the normal, and that difference is mainly quantified by the skewness (\(\gamma_1\)) and excess kurtosis (\(\gamma_2\)) of the alternative distribution. For the normal distribution, \(\gamma_1 = 0\) and \(\gamma_2 = 0\).

Since the Shapiro–Wilk test has no analytical power formula as a function of \(n\), this calculator uses the Jarque–Bera approximation, which combines skewness and kurtosis into an omnibus statistic whose distribution under \(H_0\) is asymptotically \(\chi^2(2)\). This approximation gives an estimate of the required n that is conservative: the actual n required with Shapiro–Wilk tends to be smaller, since SW makes better use of the sample information than the JB test.

Power formula (Jarque–Bera approximation)

Under the alternative with shape parameters \(\gamma_1\) and \(\gamma_2\), the noncentrality parameter of the Jarque–Bera statistic for a sample of size \(n\) is:

\( \lambda(n) = n \left(\frac{\gamma_1^2}{6} + \frac{\gamma_2^2}{24}\right) \)

Under \(H_1\), the JB statistic approximately follows a noncentral chi-square distribution with 2 degrees of freedom and noncentrality parameter \(\lambda(n)\). The power of the test at level \(\alpha\) is:

\( 1 - \beta = 1 - F_{\chi^2(2,\,\lambda(n))}\!\left(\chi^2_{1-\alpha,\,2}\right) \)

The noncentral chi-square distribution is evaluated using the Poisson mixture of central chi-squares:

\( F_{\chi^2(df,\lambda)}(x) = \sum_{k=0}^{\infty} \frac{e^{-\lambda/2}(\lambda/2)^k}{k!} \cdot F_{\chi^2(df+2k)}(x) \)

The calculator searches for the minimum integer \(n \geq 3\) for which the computed power exceeds the target.

Reference distributions

The table below shows the moments and the approximate sample size needed to detect non-normality with 80% power and \(\alpha = 0.05\) (JB approximation).

Distribution γ₁ (skewness) γ₂ (excess kurtosis) Approx. n (80%, α=0.05)
Exponential 2 6 ≈ 10
Log-normal (σ = 0.5) 1.75 5.9 ≈ 11
Chi-square (2 df) 2 6 ≈ 10
Laplace (double exponential) 0 3 ≈ 52
Student's t (5 df) 0 6 ≈ 26
Uniform 0 −1.2 ≈ 130

The n values are estimates based on the JB approximation. The Shapiro–Wilk test typically requires smaller samples in practice.

Quick setup

  • Unknown alternative distribution: if you have no information about γ₁ and γ₂, use the values for the closest distribution in the table above or apply one of the presets.
  • Kurtosis only (symmetric distributions): set γ₁ = 0 and enter the expected γ₂. Keep in mind that detecting kurtosis without skewness requires considerably larger samples.
  • Skewness only: set γ₂ = 0 and enter γ₁. Highly skewed distributions (|γ₁| > 1.5) can be detected with small samples.
  • Alpha: 0.05 is the standard. In confirmatory studies where normality is a critical assumption, consider α = 0.10 to gain power.
  • Power: 0.80 is the usual minimum. For studies where failing to meet normality has serious consequences, use 0.90.

Worked example

A researcher expects response times in an experiment to follow an exponential distribution (\(\gamma_1 = 2\), \(\gamma_2 = 6\)). They want to plan the study so that, if the data really do come from an exponential distribution, the Shapiro–Wilk test rejects normality at least 80% of the time with \(\alpha = 0.05\).

Step 1 — Noncentrality parameter:

\( \lambda(n) = n\!\left(\frac{2^2}{6} + \frac{6^2}{24}\right) = n\!\left(\frac{4}{6} + \frac{36}{24}\right) = n\!\left(0.6\overline{6} + 1.5\right) = n \cdot 2.1\overline{6} \)

Step 2 — Critical value: \(\chi^2_{0.95,\,2} \approx 5.991\).

Step 3 — Power for n = 10:

\( \lambda(10) = 10 \times 2.1\overline{6} \approx 21.67 \)

\( 1 - \beta \approx 1 - F_{\chi^2(2,\,21.67)}(5.991) \approx 0.83 \geq 0.80 \checkmark \)

With as few as n = 10 observations, the target power of 80% is exceeded. This reflects that the exponential distribution deviates strongly from the normal (high skewness and kurtosis), so it is easily detectable. You can verify this by clicking the "Exponential" preset in the calculator.

Model assumptions

  • Random sample of independent observations of a single continuous variable.
  • The null hypothesis of normality is tested against an alternative with given skewness and/or kurtosis.
  • Power is approximated using the Jarque–Bera statistic.
  • Appropriate for small to moderate sample sizes.

How to interpret the result

The value \(n\) is the lower bound on the recommended sample size for the Shapiro-Wilk (SW) test to detect the specified deviation from normality with the desired power. The formula used relies on the Jarque-Bera approximation, which tends to be conservative; SW is generally more powerful than JB and can detect non-normality with somewhat smaller samples. Always round up. If you anticipate data loss, divide \(n\) by \((1 - \text{dropout rate})\) to obtain the required recruitment. Keep in mind that SW is only designed for \(3 \leq n \leq 5000\); for \(n > 5000\) it is not directly applicable.

The power of SW to detect non-normality depends on the type of deviation and on \(n\): the test is especially powerful against symmetric distributions with heavy tails (leptokurtic) or light tails (platykurtic), and somewhat less effective for moderately skewed distributions with small samples. For \(n < 8\), the power of SW is very low regardless of the effect; if your sample is very small, normality tests have limited practical value and it is preferable to rely on the study design and graphical tools (histogram, Q-Q plot). Perform a sensitivity analysis by varying the target skewness or kurtosis parameter to see how much the required \(n\) changes.

If the computed \(n\) exceeds 5000, the SW test is not applicable and you should use alternatives such as Kolmogorov-Smirnov (with the Lilliefors correction for estimated parameters), Anderson-Darling, or simply assess normality using graphical methods (Q-Q plot, histogram). With large samples, remember that the p-value of a normality test becomes very sensitive to trivial deviations; in that context, the relevant question is not "are the data exactly normal?" but "do they deviate enough from normality to compromise the statistical procedure?". Once you have collected the data, run the normality test with the Shapiro-Wilk calculator and interpret the result together with the Q-Q plot.

References

  • Razali, N. M. & Wah, Y. B. (2011). Power comparisons of Shapiro–Wilk, Kolmogorov–Smirnov, Lilliefors and Anderson–Darling tests. Journal of Statistical Modeling and Analytics, 2(1), 21–33.
  • D'Agostino, R. B. (1990). A suggestion for using powerful and informative tests of normality. The American Statistician, 44(4), 316–321.
  • Jarque, C. M. & Bera, A. K. (1987). A test for normality of observations and regression residuals. International Statistical Review, 55(2), 163–172.
  • Shapiro, S. S. & Wilk, M. B. (1965). An analysis of variance test for normality (complete samples). Biometrika, 52(3–4), 591–611.

Frequently asked questions

  • What is skewness (γ₁) and excess kurtosis (γ₂)? Skewness measures the degree of tilt in the distribution (\(\gamma_1 = 0\) for symmetric distributions). Excess kurtosis measures the heaviness of the tails relative to the normal (\(\gamma_2 = 0\) for the normal, positive for heavier tails). Any deviation from these zero values indicates non-normality.
  • Why use the Jarque–Bera approximation? Because it provides an analytical power formula based on the noncentral chi-square distribution, allowing the sample size to be computed without simulation. The estimate is conservative: SW generally requires fewer observations in practice.
  • What sample sizes is the Shapiro–Wilk test valid for? For 3 ≤ n ≤ 5000. For n < 8 power is very low. For n > 5000, the test is excessively sensitive; it is recommended to combine it with graphical analysis (Q-Q plot).
  • Is this calculator valid for detecting kurtosis without skewness? Yes. With γ₁ = 0, the noncentrality parameter reduces to λ(n) = n·γ₂²/24. Symmetric distributions with high kurtosis (Student's t, Laplace) require larger samples than skewed distributions at a comparable distance from the normal.