Skip to content
DeepForgeby svx
All problems
MediumML Fundamentalsml-253

Heteroscedastic Residual Correlation

Problem

Measure heteroscedasticity as the absolute Pearson correlation between |residual| and the fitted values.

Return 0.0 when a variance is 0 or input is empty.

Hint

A growing spread of residuals with fitted values signals heteroscedasticity.

Test cases

case 1
in: [[1,-1,2,-2],[1,2,3,4]]
expected: 0.8944271909999159
case 2
in: [[1,1,1],[1,2,3]]
expected: 0
case 3
in: [[1,-1],[1,2]]
expected: 0
case 4
in: [[],[]]
expected: 0
Starter codePython
def heteroscedastic_correlation(residuals, fitted):
    # Your code here
    pass

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