liveBook · Manning

Adjusted r-squared

As explained in Effective Data Analysis

Adjusted R-squared is a version of R-squared that penalizes the score for additional variables included in a model.

Adjusted R-squared is a regression metric that modifies R-squared to account for the number of predictors. R-squared measures the proportion of variation in an outcome explained by the predictors, but it increases when more predictors are added. Adjusted R-squared can fall if an added predictor does not improve fit enough to justify the extra complexity. section 9.1.2

Use adjusted R-squared when deciding whether a more complex regression model earns its extra predictors. It helps balance fit against complexity; it does not replace other checks. The overall F-test assesses whether predictors collectively influence the outcome, while residual plots can reveal problems that a summary score misses. section 9.1.2 section 9.2.2

Reading a model summary

A housing-price model using square footage and bedroom count reports R-squared of 0.836 and an adjusted R-squared shown as identical. In a model of daily rat-sighting calls, R-squared is 0.588 and adjusted R-squared is only marginally lower, suggesting little complexity penalty at that stage. Neither comparison alone establishes that the model is sound: inspect the remaining diagnostics and data. section 9.1.2 section 9.2.2

import statsmodels.api as sm

import pandas as pd
housing_prices = pd.read_csv("housing_prices.csv")     #1

X = housing_prices[["sq_footage", "n_bedrooms"]]
y = housing_prices["price"]     #2
X = sm.add_constant(X)     #3

model = sm.OLS(y, X).fit()     #4
print(model.summary())

Fit an OLS housing-price regression in statsmodels and print its summary to find R-squared and adjusted R-squared together. section 9.1.2

How Effective Data Analysis covers it

How deep it goes
Defines the adjustment and interprets reported scores, without deriving its formula.
Examples
Uses housing-price and daily rat-sighting regressions to compare adjusted R-squared with R-squared in model summaries.
What it assumes
Builds on R-squared and regression predictors while explaining the adjustment without a mathematical derivation.
What you can do after
Evaluate/understand whether added regression predictors improve fit enough to offset their complexity, while checking other diagnostics.
How it connects
Connects adjusted R-squared to R-squared, predictor selection, F-tests, and residual diagnostics.

Also explained in

Compare how 3 books explain adjusted r-squared →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Effective Data Analysis. The section links point to the parts of the book it draws on.