Skip to content
DeepForgeby svx
All problems
EasyStatisticsst-203

Ridge Estimator Bias

Problem

Return the bias of the ridge slope relative to OLS: Sxy/(Sxx + lambda) - Sxy/Sxx. Return 0.0 when Sxx or Sxx + lambda is zero.

Hint

Ridge always shrinks the slope toward zero, so the bias is negative for positive Sxy.

Test cases

case 1
in: [10,5,5]
expected: -0.16666666666666669
case 2
in: [10,5,0]
expected: 0
case 3
in: [10,5,10]
expected: -0.25
case 4
in: [0,5,5]
expected: 0
case 5
in: [4,8,4]
expected: -1
Starter codePython
def ridge_bias(sxx, sxy, lam):
    # Your code here
    pass

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