Fair R Squared
Each row of X holds the predictors of one observation, and y holds the outcomes. Fit ordinary least squares with an intercept and return the adjusted R squared, which, unlike plain R squared, does not rise just because predictors were added.
Example 1
X [[1,5],[2,3],[3,4],[4,1],[5,2],[6,6]]
y [8,16,19,30,33,30]
returns 0.9987705980705096
About 0.86 of the variation is explained once the two predictors are paid for.
Constraints
Xhas 2 or 3 columns and 6 to 40 rows
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More statsmodels problems
- Group GapsEasy
- Is the Share DifferentEasy
- Is the Slope RealEasy
- Prices for New RowsEasy
- Range for the SlopeEasy
- Two CausesEasy
- Better of Two ModelsMedium
- Chance of YesMedium