Lesson 13
Adjusted R-Squared and Model Size
Big question
Why can R-squared rise when a variable adds little value?
Lesson progress
Complete checkpoints as you learn
Learning objectives
- Explain adjusted r-squared and model size in plain language.
- Use precision control correctly in an interpretation.
- Connect the lesson idea to a formula, graph, Python result, or real example.
Simple explanation
Ordinary R-squared never falls when a regressor is added. Adjusted R-squared adds a penalty for model size, so it can fall when a new variable is not useful enough.
Key terms
- Precision control
- A safe control that can reduce residual variation and improve precision.
- Standardized coefficient
- A slope measured in standard deviation units for both the explanatory variable and the dependent variable.
- Turning point
- The value of x where the fitted quadratic slope is zero.
Core formula
Use plain-language interpretation before algebra.
Example
M6_POLICY_CONTROLS is a synthetic teaching dataset for adjusted r-squared and model size. It is designed to practice model fit without presenting fabricated real-world empirical findings.
Interactive visual
Add candidate controls and watch R-squared, adjusted R-squared, and interpretability move in different directions.
Original Module 6 visual for Adjusted R-Squared and Model Size.
y variable
wage
The dependent variable. It is the outcome students want to explain.
x variable
education
The explanatory variable. It is used to describe changes in wage.
Live Python
Adjusted R-Squared and Model Size Python example
Adjusted R-Squared and Model Size Python example
Stdout
Run Python to see results here.
Status / stderr
Ready to run Python in your browser.
Line-by-line guide
- Line 1Load a Python library needed for data work or regression.
- Line 2Load a Python library needed for data work or regression.
- Line 4Load the dataset into a pandas DataFrame.
- Line 5Create or update a Python object used in the analysis.
- Line 6Run this Python instruction as part of the lesson workflow.
- Line 7Run this Python instruction as part of the lesson workflow.
- Line 8Run this Python instruction as part of the lesson workflow.
- Line 9Run this Python instruction as part of the lesson workflow.
- Line 10Run this Python instruction as part of the lesson workflow.
- Line 11Add an intercept column to the regression design matrix.
- Line 12Display a result so students can inspect the output.
Python walkthrough
- 1Load the synthetic teaching dataset from the Module 6 public data folder.
- 2Create transformed variables only after checking their meaning and valid support.
- 3Fit a regression that matches the lesson's interpretation target.
- 4Print coefficient or prediction summaries that students can connect to the formula.
- 5Use comments and output labels so no empirical result is presented without context.
Live notebook
Run this lesson as a notebook
Open an editable notebook cell-by-cell, run Python in the browser, and download the `.ipynb` file for later.
Related dataset
M6_POLICY_CONTROLS
Estimated time
25 to 40 min
Packages
pandas, numpy, statsmodels, patsy
Expected output
A regression or inference table with coefficients, uncertainty, and short interpretation notes.
Learning goals
- Load and inspect M6_POLICY_CONTROLS.
- Run the Python cells connected to Adjusted R-Squared and Model Size.
- Interpret the output using adjusted R-squared and model comparison.
Common errors
- File not found: check that M6_POLICY_CONTROLS.csv is installed or use the course data folder.
- Package import error: use the browser notebook first, then download for local Jupyter if your local packages differ.
- Column name error: compare your variable names with the dataset variables listed for this notebook.
Dataset path helper
import pandas as pd
df = pd.read_csv("/data/module-6/M6_POLICY_CONTROLS.csv")
df.head()Interactive activity
AdjustedRSquaredPenaltyLab
Watch adjusted R-squared respond
Add variables and compare R-squared with adjusted R-squared.
Inputs
Try it yourself
Write one plain-English sentence explaining the main idea from this lesson.
Common mistakes
Check these before you move on.
Return to the lesson assumptions, units, diagnostics, and source evidence to replace this shortcut with a defensible interpretation.
Quick quiz
Which interpretation is most careful for Adjusted R-Squared and Model Size?
Quick quiz
What is the main mistake to avoid in Adjusted R-Squared and Model Size?
Quick quiz
Why is M6_WAGE_SCALING a reasonable practice dataset here?
Key takeaway
Adjusted R-Squared and Model Size helps students make multiple regression more flexible while keeping interpretation precise and honest.