All problems
Item-Total Correlation
Problem
Return the corrected item-total correlation: the Pearson correlation between the item scores and the total minus the item. Return 0.0 when there are fewer than two responses, lengths differ, or either vector is constant.
Hint
Removing the item from the total prevents part-whole inflation.
Test cases
case 1
in: [[1,2,3,4],[3,5,7,9]]
expected: 1
case 2
in: [[4,3,2,1],[5,5,5,5]]
expected: -1
case 3
in: [[1,1,2,2],[2,2,4,4]]
expected: 1
case 4
in: [[2,2,2],[3,4,5]]
expected: 0
case 5
in: [[1,2],[3]]
expected: 0
Starter codePython
def item_total_correlation(item, total):
# Your code here
pass5 test cases · run your code against them in the editor