Logo

ICC

Updated 2023-11-06 13:22:40.837000

Syntax

SELECT [westclintech].[wct].[ICC](
  <@InputData_RangeQuery, nvarchar(max),>
 ,<@TypeTest, nvarchar(4000),>
 ,<@Alpha, float,>
 ,<@R0, float,>
 ,<@RV, nvarchar(4000),>)

Description

Use the scalar function ICC 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.

@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.

@RV

the value to be returned by the function. Use the following values:

{"columns":[{"field":"'@RV'"},{"field":"the test statistic"}],"rows":[{"'@RV'":"'F'","the test statistic":"the F value"},{"'@RV'":"'DF1'","the test statistic":"the degrees of freedom 1 for the F distribution"},{"'@RV'":"'DF2'","the test statistic":"the degrees of freedom 2 for the F distribution"},{"'@RV'":"'P'","the test statistic":"the p-value (calculated from the F distribution)"},{"'@RV'":"'FL'","the test statistic":"the lower confidence level, for the specified alpha, of the F distribution"},{"'@RV'":"'FU'","the test statistic":"the upper confidence level, for the specified alpha"},{"'@RV'":"'LB'","the test statistic":"the p-value associated with FL"},{"'@RV'":"'UB'","the test statistic":"the p-value associated with FU"}]}

@InputData_RangeQuery

a T-SQL statement, as a string, that specifies the subject, rater, and rating values.

@TypeTest

ICC 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

float

Remarks

The function is insensitive to order; it does not matter what order the ratings are passed in.

Subjects, raters and 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.stat,
       wct.ICC('SELECT s,rater,rating FROM #i', @case_icc, NULL, NULL, p.stat) as 
                 stat_value
FROM
(
    SELECT 'r'
    UNION ALL
    SELECT 'F'
    UNION ALL
    SELECT 'df1'
    UNION ALL
    SELECT 'df2'
    UNION ALL
    SELECT 'p'
    UNION ALL
    SELECT 'FL'
    UNION ALL
    SELECT 'FU'
    UNION ALL
    SELECT 'LB'
    UNION ALL
    SELECT 'UB'
) p(stat);

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"}]}