Skip to content
DeepForgeby svx
All problems
HardStatisticsst-181

ICC(2,1)

Problem

Return the two-way random effects intraclass correlation ICC(2,1) for a subjects-by-raters matrix: (MSR - MSE) / (MSR + (k-1)*MSE + k*(MSC - MSE)/n), using two-way ANOVA mean squares. Return 0.0 when there are fewer than two subjects or raters, the matrix is ragged, or the denominator is zero.

Hint

This is the absolute-agreement single-measure ICC.

Test cases

case 1
in: [[[1,1],[2,2],[3,3]]]
expected: 1
case 2
in: [[[1,2],[2,1],[3,3]]]
expected: 0.6
case 3
in: [[[1,2],[3,4]]]
expected: 0.8
case 4
in: [[[1,2],[3,4],[5,6]]]
expected: 0.8888888888888888
case 5
in: [[[1,2],[3]]]
expected: 0
Starter codePython
def icc_2_1(matrix):
    # Your code here
    pass

5 test cases · run your code against them in the editor