shapiro.test
Shapiro-Wilk Test for Normality

Description

Computes the Shapiro-Wilk W-statistic for testing for departures from normality.

Usage

shapiro.test(x)

Arguments

x a numeric vector. Missing values (NAs) and infinite values (Infs) are allowed, but are ignored in the calculation. The length of x, after dropping infinite values, must be greater than 3 and less than 5000.

Details

The calculations for this test are based on the algorithm by Royston (1995).
Value
returns an object of class htest that represent the result of the Shapiro-Wilk normality test. This object contains the following components:
statistic value of the test statistic along with the names attribute W.
p.value p-value for the test.
data.name a character string that describes the actual name of the data used in the test.
method name of the test applied, for example Shapiro-Wilk Normality Test.
Background
Shapiro and Wilk's W-statistic is a well-known goodness of fit test for the normal distribution. It is attractive because it has a simple, graphical interpretation. You can think of it as an approximate measure of the correlation in a normal quantile-quantile plot of the data.
Differences Between TIBCO Enterprise Runtime for R And Open-Source R
When you run the shapiro.test on a dataset with missing values (NA), TIBCO Enterprise Runtime for R reports a warning about NAs that is not shown in R. (The test output is the same.)
In R, shapiro.test fails if the data includes Infs. TIBCO Enterprise Runtime for R removes the non-finite value(s), issues a warning about them, and then runs the test on the remaining values.
References
Royston, P. 1982. Algorithm AS 181: The W test for Normality. Applied Statistics. Volume 31. 176-180.
Royston, P. 1982. An extension of the Shapiro and Wilk W test for normality to large samples. Applied Statistics. Volume 31. 115-124.
Royston, P. 1995. A remark on algorithm AS 181: the W-test for normality. Applied Statistics. Volume 44. 547-551.
Shapiro, S. S. and Wilk, M. B. 1965. An analysis of variance test for normality (complete samples). Biometrika. Volume 52. 591-611.
See Also
chisq.gof, ks.gof, cdf_cmp.sgm, qqnorm, htest.object.
Examples
# Should not be significant
shapiro.test(rnorm(30)) 

# Should be significant. shapiro.test(runif(50))

Package stats version 6.0.0-69
Package Index