Lesson 10

Goodness of Fit in Multiple Regression

Big question

Does a higher R-squared mean a better causal model?

Lesson progress

Complete checkpoints as you learn

0% complete0 checkpoint streak
Progress tracking available after sign-in. Sign in to save your work.
Big question
Concept
Activity
Quiz

Learning objectives

  • Explain goodness of fit in multiple regression in plain language.
  • Use control variable correctly in an interpretation.
  • Connect the lesson idea to a formula, graph, Python result, or real example.

Simple explanation

R-squared measures the share of sample variation explained by fitted values. It usually rises when variables are added, even if the new variable is not substantively useful.

Key terms

control variable
A variable included to hold an observed factor fixed while interpreting another coefficient.
BLUE
Best Linear Unbiased Estimator under the Gauss-Markov assumptions.
variance inflation factor
A measure of how much collinearity inflates a coefficient variance.

Core formula

R2=1SSR/SSTR2 = 1 - SSR / SST

Use plain-language interpretation before algebra.

Example

Fit and causal validity are different ideas. An irrelevant control can raise R-squared while making interpretation less precise.

Interactive visual

Add-variable R-squared experiment

Original Module 3 visual for Goodness of Fit in Multiple Regression.

wage_sample.csv

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

Goodness of Fit in Multiple Regression Python example

Goodness of Fit in Multiple Regression Python example

Stdout

Run Python to see results here.

Status / stderr

Ready to run Python in your browser.

Line-by-line guide

  1. Line 1Load a Python library needed for data work or regression.
  2. Line 2Load a Python library needed for data work or regression.
  3. Line 3Load a Python library needed for data work or regression.
  4. Line 5Load the dataset into a pandas DataFrame.
  5. Line 6Create a log version of the variable so coefficients can be read approximately as percentages.
  6. Line 7Add an intercept column to the regression design matrix.
  7. Line 8Create or update a Python object used in the analysis.
  8. Line 9Estimate an ordinary least squares regression.
  9. Line 10Display a result so students can inspect the output.

Python walkthrough

  1. 1Load the dataset and keep only variables needed for the current model.
  2. 2Construct the dependent variable and explanatory-variable matrix.
  3. 3Add a constant so the regression includes an intercept.
  4. 4Fit OLS and interpret coefficients with the controls held fixed.

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

WAGE1

Estimated time

25 to 40 min

Packages

pandas, numpy

Expected output

Printed Python results that can be compared with the lesson explanation.

Learning goals

  • Load and inspect WAGE1.
  • Run the Python cells connected to Goodness of Fit in Multiple Regression.
  • Interpret the output using R-squared and model comparison.

Common errors

  • File not found: check that WAGE1.DTA 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_stata("/data/WAGE1.DTA")
df.head()

Interactive activity

MLRAssumptionCards

Add a variable and read fit carefully

Separate higher R-squared from stronger causal evidence.

MEAP93

Controlled prediction

Simple prediction2.12
Multiple-regression prediction1.76
Absolute residual signal0.25

Interpretation sentence

Holding experience and tenure fixed, one more year of education changes predicted log wage by about 0.075 in this teaching setup.

Residual sketch

Variable role check

In a wage model with education as the focal x, classify experience.

Precision check

Larger samples tighten estimates. Under the Gauss-Markov assumptions, OLS has the smallest variance among linear unbiased estimators.

Control overlap

VIF: 2.22

SE index: 0.136

Try it yourself

Write one plain-English sentence explaining the main idea from this lesson.

Common mistakes

Check these before you move on.

A regression coefficient describes a pattern unless the assumptions or research design support a causal interpretation.

Quick quiz

What is the safest interpretation focus in Goodness of Fit in Multiple Regression?

Quick quiz

Which interpretation habit is most important in Goodness of Fit in Multiple Regression?

Quick quiz

Why is ATTEND a reasonable practice dataset here?

Key takeaway

Goodness of Fit in Multiple Regression helps turn multiple regression output into a careful ceteris paribus interpretation.