Login     Register

        Contact Us     Search

XLeratorDB/statistics Documentation

SQL Server Kendall's Tau function


KENDALLT

Updated: 24 May 2013


Use the scalar function KENDALLT to calculate Kendall’s tau (t), a non-parametric measure of association based on the number of concordances and discordances in paired observations. Concordance occurs when paired observations vary together and discordance occurs when paired observations vary differently. The equation for Kendall’s tau is:

XLeratorDB formula for KENDALLT function for SQL Server
Where
C is the number of concordant pairs
D is the number of discordant pairs
n is the number of pairs
T is the number of x ties
U is the number of y ties
 
The function also calculates


Syntax
SELECT [wctStatistics].[wct].[KENDALLT](
  <@x_y_Query, nvarchar(max),>
 ,<@RV, nvarchar(4000),>)
Arguments
@InputData_RangeQuery
a T-SQL statement, as a string, that specifies the subject, rater, and rating values.
@RV
the value to be returned by the function. Use the following values:

'TAU','TAU_B','TAUB'
tau b
'TAU_A','TAUA'
tau a
'Z','Z_B','ZB'
the z statistic for tau b
'Z_A','ZA'
the z statistic for tau a
'P','P_B','PB'
the p value for tau b
'P_A','PA'
the p value for tau a
'SD','SD_B','SDB'
the standard deviation for tau b
'SD_A','SDB'
the standard deviation for tau a
'C'
the number of concordant pairs
'D'
the number of discordant pairs
'S'
C – D
'T'
the number of x ties
'U'
the number of y ties
'N'
the number of pairs
 
Return Type
float
Remarks
·         The function is insensitive to order.
·         If x is NULL or y is NULL the pair is not included in the calculations.
·         To return multiple values, use the table-valued function KENDALLT_TV.
Examples
SELECT *
INTO #k
FROM (
      SELECT 2.5,1 UNION ALL
      SELECT 2.5,1 UNION ALL
      SELECT 2.5,1 UNION ALL
      SELECT 2.5,1 UNION ALL
      SELECT 5,2 UNION ALL
      SELECT 6.5,1 UNION ALL
      SELECT 6.5,1 UNION ALL
      SELECT 10,2 UNION ALL
      SELECT 10,1 UNION ALL
      SELECT 10,1 UNION ALL
      SELECT 10,1 UNION ALL
      SELECT 10,1 UNION ALL
      SELECT 14,1 UNION ALL
      SELECT 14,1 UNION ALL
      SELECT 14,2 UNION ALL
      SELECT 16,2 UNION ALL
      SELECT 17,2
      ) n(x,y)
 
SELECT p.stat
,wct.KENDALLT('SELECT x,y FROM #k', p.stat) k
FROM (
      SELECT 'tau_a' UNION ALL
      SELECT 'tau_b' UNION ALL
      SELECT 'C' UNION ALL
      SELECT 'D' UNION ALL
      SELECT 'S' UNION ALL
      SELECT 'T' UNION ALL
      SELECT 'U' UNION ALL
      SELECT 'za' UNION ALL
      SELECT 'zb' UNION ALL
      SELECT 'SDa' UNION ALL
      SELECT 'SDb' UNION ALL
      SELECT 'pa' UNION ALL
      SELECT 'pb' UNION ALL
      SELECT 'N' )p(stat)
     
DROP TABLE #k
This produces the following result.



Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service