Login     Register

        Contact Us     Search

XLeratorDB/statistics Documentation

SQL Server Shapiro-Francia test


Updated: 27 June 2012

Note: This documentation is for the SQL2008 (and later) version of this XLeratorDB function, it is not compatible with SQL Server 2005.
Click here for the SQL2005 version of the SFTEST function

Use the aggregate function SFTEST to perform the Shapiro-Francia test for the composite hypothesis of normality. The test statistic of the Shapiro-Francia test is simply the squared correlation between the ordered sample values and the (approximated) expected ordered quantiles from the standard normal distribution. The p-value is computed from the formula given by Royston (1993).
syntax for sql server analytic function SFTEST
the sample values. @x is an expression of type float or of a type that can be implicitly converted to float.
identifies the return value as either the Shapiro-Francia statistic (w) or the p-value (p).
Return Types
·         If @x is null then @x is not included in the aggregate.
·         @statistic must be invariant for the GROUP.
·         SFTEST is an aggregate function and follows the same conventions as all other aggregate functions in SQL Server.
·         @x must have at least 3 rows
In this example, we have two samples, which we have identified as sample 1 and sample 2 and we perform the Shapiro Francia test on both in a single SELECT, grouping the results by sample number.
SELECT n.s as sample_num
,wct.SFTEST(x,'w') as w_observed
,wct.SFTEST(x,'p') as p_value
      ) n(s,x)
This produces the following result
sample_num             w_observed                p_value
----------- ---------------------- ----------------------
          1      0.917024201827551     0.0810926381951407
          2      0.956959220606241      0.411915065401292

Copyright 2008-2023 Westclintech LLC         Privacy Policy        Terms of Service