g01dd calculates Shapiro and Wilk's statistic and its significance level for testing Normality.
Public Shared Sub g01dd ( _ x As Double(), _ n As Integer, _ calwts As Boolean, _ a As Double(), _ <OutAttribute> ByRef w As Double, _ <OutAttribute> ByRef pw As Double, _ <OutAttribute> ByRef ifail As Integer _ )
public: static void g01dd( array<double>^ x, int n, bool calwts, array<double>^ a, [OutAttribute] double% w, [OutAttribute] double% pw, [OutAttribute] int% ifail )
- Type: array<System..::..Double>()An array of size [n]On entry: the ordered sample values, , for .
- Type: System..::..Int32On entry: , the sample size.Constraint: .
- Type: System..::..Boolean
- Type: array<System..::..Double>()An array of size [n]On entry: if calwts has been set to false then before entry a must contain the weights as calculated in a previous call to g01dd, otherwise a need not be set.On exit: the weights required to calculate .
- Type: System..::..Double%On exit: the value of the statistic, .
- Type: System..::..Double%On exit: the significance level of .
g01dd calculates Shapiro and Wilk's statistic and its significance level for any sample size between and . It is an adaptation of the Applied Statistics Algorithm AS R94, see Royston (1995). The full description of the theory behind this algorithm is given in Royston (1992).
Given a set of observations sorted into either ascending or descending order ( (M01CAF not in this release) may be used to sort the data) this method calculates the value of Shapiro and Wilk's statistic defined as:
where is the sample mean and , for , are a set of ‘weights’ whose values depend only on the sample size .
On exit, the values of , for , are only of interest should you wish to call the method again to calculate and its significance level for a different sample of the same size.
Royston J P (1982) Algorithm AS 181: the test for normality Appl. Statist. 31 176–180
Royston J P (1986) A remark on AS 181: the test for normality Appl. Statist. 35 232–234
Royston J P (1992) Approximating the Shapiro–Wilk's test for non-normality Statistics & Computing 2 117–119
Royston J P (1995) A remark on AS R94: A remark on Algorithm AS 181: the test for normality Appl. Statist. 44(4) 547–551
Errors or warnings detected by the method:
On entry, . On entry, . On entry, the elements in x are not in ascending or descending order or are all equal.
There may be a loss of significant figures for large .
The time taken by g01dd depends roughly linearly on the value of .
For very small samples the power of the test may not be very high.
The contents of the array a should not be modified between calls to g01dd for a given sample size, unless calwts is reset to true before each call of g01dd.
The Shapiro and Wilk's test is very sensitive to ties. If the data has been rounded the test can be improved by using Sheppard's correction to adjust the sum of squares about the mean. This produces an adjusted value of ,
where is the rounding width. can be compared with a standard Normal distribution, but a further approximation is given by Royston (1986).
This example tests the following two samples (each of size ) for Normality.
The elements of a are calculated only in the first call of g01dd, and are re-used in the second call.
|1||, , , , , , , , , , , , , , , , , , ,|
|2||, , , , , , , , , , , , , , , , , , ,|