KENDALLW
Updated 2023-11-06 16:20:40.233000
Syntax
SELECT [westclintech].[wct].[KENDALLW](
<@InputData_RangeQuery, nvarchar(max),>
,<@CorrectTies, bit,>
,<@RV, nvarchar(4000),>)
Description
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:
Wherer is the sum of the ranks of the ratings for all raters for each subjectµ2 is the second central momentnr is the number of ratersns 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 ratergj is the number of unique ratings within a rater
Arguments
@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:
{
"columns": [
{
"field": "RV"
},
{
"field": "Description"
}
],
"rows": [
{
"RV": "'W'",
"Description": "the Kendall W statistic"
},
{
"RV": "'X'",
"Description": "the chi-squared statistic"
},
{
"RV": "'DF1'",
"Description": "the degrees of freedom"
},
{
"RV": "'P'",
"Description": "the p-value"
}
]
}
@InputData_RangeQuery
a T-SQL statement, as a string, that specifies the subject, rater, and rating values.
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.
{"columns":[{"field":"stat"},{"field":"k","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"stat":"W","k":"0.501921470342523"},{"stat":"X","k":"28.6095238095238"},{"stat":"df1","k":"19"},{"stat":"p","k":"0.072380354693757"}]}