All problems
Adjusted R-Squared from Summary Statistics
Problem
Return the adjusted R-squared 1 - (1 - R^2)*(n - 1)/(n - p - 1), where p is the number of predictors. Return 0.0 when n - p - 1 <= 0.
Hint
The adjustment penalizes each additional predictor.
Test cases
case 1
in: [0.8,100,2]
expected: 0.7958762886597939
case 2
in: [0.5,10,1]
expected: 0.4375
case 3
in: [0.9,20,5]
expected: 0.8642857142857143
case 4
in: [0.5,3,2]
expected: 0
case 5
in: [0.6,5,3]
expected: -0.6000000000000001
Starter codePython
def adjusted_r_squared(r2, n, p):
# Your code here
pass5 test cases · run your code against them in the editor