All problems
Wilks Lambda Lite
Problem
Return Wilks' lambda det(E)/det(E + H) for 2x2 within-group (E) and hypothesis (H) SSCP matrices. Return 0.0 when the shapes are not 2x2 or det(E + H) is zero.
Hint
Lambda is 1 when the effect adds nothing and approaches 0 for strong effects.
Test cases
case 1
in: [[[4,1],[1,3]],[[2,0.5],[0.5,1]]]
expected: 0.5057471264367817
case 2
in: [[[1,0],[0,1]],[[1,0],[0,1]]]
expected: 0.25
case 3
in: [[[2,1],[1,2]],[[0,0],[0,0]]]
expected: 1
case 4
in: [[[1,1],[1,1]],[[2,0],[0,2]]]
expected: 0
case 5
in: [[[3,0.5],[0.5,2]],[[1,0.2],[0.2,1]]]
expected: 0.49956559513466553
Starter codePython
def wilks_lambda(sscp_e, sscp_h):
# Your code here
pass5 test cases · run your code against them in the editor