Skip to content
DeepForgeby svx
All problems
HardStatisticsst-354

Leverage Value in Simple Regression

Problem

The leverage of observation x is h = 1/n + (x - xbar)^2 / Sxx.

Given the predictor values and a particular x value, return the leverage.

Hint

Points far from the center of the predictor have higher leverage.

Test cases

case 1
in: [[1,2,3],2]
expected: 0.3333333333333333
case 2
in: [[1,2,3],3]
expected: 0.8333333333333333
case 3
in: [[1,2,3],1]
expected: 0.8333333333333333
Starter codePython
def leverage_in_simple_regression(xs, x_value):
    # Your code here
    pass

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