KENDALLW
Updated: 24 May 2013
Use the scalar function KENDALLW to calculate Kendall’s coefficient of concordance (w) as an index of inter-rater reliability for ordinal data. The equation for Kendall’s w is:
Where
r is the sum of the ranks of the ratings for all raters for each subject
µ2 is the second central moment
nr is the number of raters
ns is the number of subjects being rated
The equation for Kendall’s w corrected for ties is:
Where
ti is a count of each rating within a rater
gj is the number of unique ratings within a rater
Syntax
SELECT [wctStatistics].[wct].[KENDALLW](
<@InputData_RangeQuery, nvarchar(max),>
,<@CorrectTies, bit,>
,<@RV, nvarchar(4000),>)
Arguments
@InputData_RangeQuery
a T-SQL statement, as a string, that specifies the subject, rater, and rating values.
@CorrectTies
a bit value identifying whether the coefficient should be corrected for ties within raters.
@RV
the value to be returned by the function. Use the following values:
'W'
|
the Kendall w statistic
|
'X'
|
the chi-squared statistic
|
'DF1'
|
the degrees of freedom
|
'P'
|
the p-value
|
Return Type
float
Remarks
· The function is insensitive to order and automatically matches all the ratings for a subject
· NULL values are excluded
Examples
SELECT n.s
,x.rater
,x.rating
INTO #k
FROM (
SELECT 1,3,3,2 UNION ALL
SELECT 2,3,6,1 UNION ALL
SELECT 3,3,4,4 UNION ALL
SELECT 4,4,6,4 UNION ALL
SELECT 5,5,2,3 UNION ALL
SELECT 6,5,4,2 UNION ALL
SELECT 7,2,2,1 UNION ALL
SELECT 8,3,4,6 UNION ALL
SELECT 9,5,3,1 UNION ALL
SELECT 10,2,3,1 UNION ALL
SELECT 11,2,2,1 UNION ALL
SELECT 12,6,3,2 UNION ALL
SELECT 13,1,3,3 UNION ALL
SELECT 14,5,3,3 UNION ALL
SELECT 15,2,2,1 UNION ALL
SELECT 16,2,2,1 UNION ALL
SELECT 17,1,1,3 UNION ALL
SELECT 18,2,3,3 UNION ALL
SELECT 19,4,3,2 UNION ALL
SELECT 20,3,4,2
)n(s,r1,r2,r3)
--This CROSS APPLY UNPIVOTS the input data
--into third normal form
CROSS APPLY(
SELECT 'r1', r1 UNION ALL
SELECT 'r2', r2 UNION ALL
SELECT 'r3', r3
)x(rater,rating)
SELECT p.stat
,wct.KENDALLW('SELECT s,rater,rating FROM #k', 'False', p.stat)k
FROM (
SELECT 'W' UNION ALL
SELECT 'X' UNION ALL
SELECT 'df1' UNION ALL
SELECT 'p') p(stat)
DROP TABLE #k
This produces the following result.