All problems
Breusch-Pagan Lite
Problem
Return the Pearson correlation between x and the squared residuals, a quick heteroscedasticity indicator. Return 0.0 when fewer than two points are given or either variable has zero variance.
Hint
A strong correlation suggests the error variance changes with x.
Test cases
case 1
in: [[1,2,3,4],[1,4,9,16]]
expected: 0.9163023485215754
case 2
in: [[0,0,0],[1,2,3]]
expected: 0
case 3
in: [[1,2,3],[4,4,4]]
expected: 0
case 4
in: [[1,2,3,4],[4,9,16,25]]
expected: 0.9461581522243414
case 5
in: [[1,2],[1,4]]
expected: 1
Starter codePython
def breusch_pagan_lite(x, residuals):
# Your code here
pass5 test cases · run your code against them in the editor