PV-WAVE Advantage > IMSL Statistics Reference Guide > Goodness of Fit > SHAPIRO_WILK_NORMALITY_TEST Function
SHAPIRO_WILK_NORMALITY_TEST Function
Performs the Shapiro-Wilk test for normality.
Usage
result = SHAPIRO_WILK_NORMALITY_TEST (x)
Input Parameters
x—Array of size n_observations (number of observations) containing the observations.
Returned Value
result–The p-value for the Shapiro-Wilk test for normality is returned.
Input Keywords
Double—If present and nonzero, then double precision is used.
Output Keywords
Shapiro_wilk_w—A scalar float for the Shapiro-Wilk W test statistic.
Discussion
The Shapiro-Wilk test for normality is thought by D’Agostino and Stevens (1986, p. 406) to be one of the best omnibus tests of normality. The function is based on the approximations and code given by Royston (1982a, b, c; and 1991). The minimum sample size is 3 and sample sizes as large as 5000 have been validated. In the Shapiro and Wilk test, W is given by
where x(i) is the ith largest order statistic and is the sample mean. Royston (1982 and 1991) gives approximations and tabled values that can be used to compute the coefficients aii = 1, ..., n, and obtains the significance level of the W statistic.
Example
This example is taken from Conover (1980, pp. 195, 364). The data consists of 50 two-digit numbers taken from a telephone book. The W test fails to reject the null hypothesis of normality at the .05 level of significance.
PRO t_shapiro_wilk_normality_test
 
  n_observations = 50; 
  x = $
      [23.0, 36.0, 54.0, 61.0, 73.0, 23.0,$
       37.0, 54.0, 61.0, 73.0, 24.0, 40.0,$
       56.0, 62.0, 74.0, 27.0, 42.0, 57.0,$
       63.0, 75.0, 29.0, 43.0, 57.0, 64.0,$
       77.0, 31.0, 43.0, 58.0, 65.0, 81.0,$
       32.0, 44.0, 58.0, 66.0, 87.0, 33.0,$
       45.0, 58.0, 68.0, 89.0, 33.0, 48.0,$
       58.0, 68.0, 93.0, 35.0, 48.0, 59.0,$
       70.0, 97.0]  
 
  ; Shapiro-Wilk test.
  p_value = SHAPIRO_WILK_NORMALITY_TEST(x, $ 
               Shapiro_wilk_w=shapiro_wilk_w) 
 
  PRINT,"p-value = ",STRING(p_value,Format="(f11.4)") 
  PRINT,"Shapiro Wilk W statistic = ", $
         STRING(shapiro_wilk_w, Format="(f11.4)") 
 
END
Output
p-value =      0.3473
Shapiro Wilk W statistic =      0.9744