Learn R Programming

normality (version 0.0.3)

Shapiro_Wilk_test: Shapiro-Wilk Normality Test

Description

Performs the Shapiro–Wilk normality test, which assesses whether a sample originates from a normally distributed population using a regression-based correlation method.

Usage

Shapiro_Wilk_test(
  x,
  alpha = 0.05,
  method = c("SWR", "SF", "SW"),
  silent = FALSE,
  summary = TRUE,
  misc = FALSE,
  resampling = TRUE
)

Value

A list.

Arguments

x

A numeric vector.

alpha

Significance threshold (default: 0.05).

method

Character (default: "SWR"). Use which modification of the test? Available options are c("SWR", "SF", "SW").

silent

Logical (default: FALSE). If FALSE, print out the results.

summary

Logical (default: TRUE). Produce a summary table.

misc

Logical (default: FALSE). Output other unimportant parameters.

resampling

Logical (default: TRUE). If TRUE, unlock the sample size limitation of the test by using sample resampling method.

Details

method

  • "SW": Shapiro–Wilk test, the original normality test proposed by Shapiro and Wilk (1965). Applicable only for sample sizes 3 <= n <= 50.

  • "SF": Shapiro–Francia test, proposed by Shapiro and Francia (1972) and subsequently simplified and extended by Royston (1993). Applicable only for sample sizes 5 <= n <= 5000.

  • "SWR": Shapiro–Wilk test with Royston's (1992) modifications for approximating the null distribution and extending the test to larger sample sizes. Applicable only for sample sizes 3 <= n <= 5000.

References

Shapiro, S.S., Wilk, M.B., 1965. An Analysis of Variance Test for Normality (Complete Samples). Biometrika 52, 591–611. https://doi.org/10.2307/2333709

Shapiro, S.S., Francia, R.S., 1972. An Approximate Analysis of Variance Test for Normality. J. Am. Stat. Assoc. 67, 215–216. https://doi.org/10.1080/01621459.1972.10481232

Royston, P., 1993. A pocket-calculator algorithm for the Shapiro–Francia test for non-normality: an application to medicine. Stat. Med. 12, 181–184. https://doi.org/10.1002/sim.4780120209

Royston, P., 1992. Approximating the Shapiro–Wilk W-test for non-normality. Stat. Comput. 2, 117–119. https://doi.org/10.1007/BF01891203

Examples

Run this code
sw <- Shapiro_Wilk_test(rnorm(20), method = "SW")
print(sw$summary)
sf <- Shapiro_Wilk_test(rnorm(100) ^ 2, method = "SF")
print(sf$summary)
swr <- Shapiro_Wilk_test(rnorm(1e6), method = "SWR")
print(swr$summary)

Run the code above in your browser using DataLab