Skip to content
DeepForgeby svx
All problems
EasyStatisticsst-058

VIF from R-Squared

Problem

Return the variance inflation factor 1 / (1 - R^2) for a predictor regressed on the other predictors. Return 0.0 when R^2 is outside [0, 1).

Hint

The denominator is the leftover variance fraction.

Test cases

case 1
in: [0.5]
expected: 2
case 2
in: [0.8]
expected: 5.000000000000001
case 3
in: [0]
expected: 1
case 4
in: [1]
expected: 0
case 5
in: [0.9]
expected: 10.000000000000002
Starter codePython
def vif_from_r2(r2):
    # Your code here
    pass

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