ICC_TV
Updated 2023-11-06 13:27:24.727000
Syntax
SELECT * FROM [westclintech].[wct].[ICC_TV](
<@InputData_RangeQuery, nvarchar(max),>
,<@TypeTest, nvarchar(4000),>
,<@Alpha, float,>
,<@r0, float,>)
Description
Use the table-valued function ICC_TV to calculate the intra-class coefficient. The ICC is used to assess the consistency of measurements made by multiple observers measuring the same quantity.
Arguments
@r0
the specification of the null hypothesis r = r0. r0 is used in the calculation of the F-value which is subsequently used in the calculation of the p-value. Must be of type float or of a type that implicitly converts to float.
@InputData_RangeQuery
a T-SQL statement, as a string, that specifies the subject, rater, and rating values.
@Alpha
the value to be used in the calculation of FL and FU. Must be of type float or of a type that implicitly converts to float.
@TypeTest
ICC_TV support six different types of ICC:• one-way, consistency, single measure — ICC(1,1), '1-1'• one-way, consistency, average measure —ICC(1,k), '1-k'• two-way, agreement, single measure — ICC(2,1), '2-1'• two-way, agreement, average measure — ICC(2,k), '2-k'• two-way, consistency, single measure — ICC(3,1), '3-1'• two-way, consistency, average measure — ICC(3,k), '3-k'
Return Type
table
{"columns": [{"field": "colName", "headerName": "Name", "header": "name"}, {"field": "colDatatype", "headerName": "Type", "header": "type"}, {"field": "colDesc", "headerName": "Description", "header": "description", "minWidth": 1000}], "rows": [{"id": "7ffb023d-1cb2-42ad-beb7-eed395ce6574", "colName": "r", "colDatatype": "float", "colDesc": "the test statistic"}, {"id": "24b47acb-7d4a-4ef2-bce3-b2d9ab14e31b", "colName": "F", "colDatatype": "float", "colDesc": "the F value"}, {"id": "cfef0821-2b7f-4338-80f1-9b2246d5d548", "colName": "df1", "colDatatype": "float", "colDesc": "the degrees of freedom 1 for the F distribution"}, {"id": "d8699fc0-2145-439a-8990-ace51df2ee3b", "colName": "df2", "colDatatype": "float", "colDesc": "the degrees of freedom 2 for the F distribution"}, {"id": "233b66c3-a316-4a08-bec2-66ee1e0a3c44", "colName": "p", "colDatatype": "float", "colDesc": "the p-value (calculated from the F distribution)"}, {"id": "3eb5727b-5783-4619-9c20-36536005c238", "colName": "FL", "colDatatype": "float", "colDesc": "the lower confidence level, for the specified alpha, of the F distribution"}, {"id": "a4f79728-1f55-46ee-90ac-cdebbca6110a", "colName": "FU", "colDatatype": "float", "colDesc": "the upper confidence level, for the specified alpha"}, {"id": "82f3d693-baed-4cd1-a3ee-dae08179aae4", "colName": "LB", "colDatatype": "float", "colDesc": "the p-value associated with FL"}, {"id": "b818ed94-33e7-4f7d-a05c-00b7dfd95cc8", "colName": "UB", "colDatatype": "float", "colDesc": "the p-value associated with FU"}]}
Remarks
The function is insensitive to order; it does not matter what order the ratings are passed in.
Subjects, raters, ratings are automatically combined by the function.
Examples
DECLARE @case_icc as varchar(3);
SET @case_icc = '1-k';
SELECT n.s,
x.rater,
x.rating
INTO #i
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)
CROSS APPLY
(
SELECT 'r1',
r1
UNION ALL
SELECT 'r2',
r2
UNION ALL
SELECT 'r3',
r3
) x(rater, rating);
SELECT p.*
FROM wct.ICC_TV('SELECT s,rater,rating FROM #i', @case_icc, NULL, NULL) k
--This CROSS APPLY UNPIVOTS the tvf columns for formatting
CROSS APPLY
(
SELECT 'r',
k.r
UNION ALL
SELECT 'F',
k.F
UNION ALL
SELECT 'df1',
k.df1
UNION ALL
SELECT 'df2',
k.df2
UNION ALL
SELECT 'p',
k.p
UNION ALL
SELECT 'FL',
k.FL
UNION ALL
SELECT 'FU',
k.FU
UNION ALL
SELECT 'LB',
k.LB
UNION ALL
SELECT 'UB',
k.UB
) p(stat, value_stat);
DROP TABLE #i;
This produces the following result.
{"columns":[{"field":"stat"},{"field":"stat_value","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"stat":"r","stat_value":"0.388925629442971"},{"stat":"F","stat_value":"1.63646228974498"},{"stat":"df1","stat_value":"19"},{"stat":"df2","stat_value":"40"},{"stat":"p","stat_value":"0.0939307271289242"},{"stat":"FL","stat_value":"0.784360793364277"},{"stat":"FU","stat_value":"3.81774284381646"},{"stat":"LB","stat_value":"-0.274923489878687"},{"stat":"UB","stat_value":"0.738065123579582"}]}