Lesson 14
Comparing Nonnested Models
Big question
How should students compare models when one is not just a larger version of the other?
Lesson progress
Complete checkpoints as you learn
Learning objectives
- Explain comparing nonnested models in plain language.
- Use prediction interval correctly in an interpretation.
- Connect the lesson idea to a formula, graph, Python result, or real example.
Simple explanation
Nonnested models cannot be compared with a simple exclusion F test. Students should compare research purpose, variables, sample, fit measures, and out-of-sample logic.
Key terms
- Prediction interval
- An interval for an individual future outcome, usually wider than an interval for the conditional mean.
- Semi-elasticity
- A coefficient interpretation involving a level change in one variable and a percent change in another.
- Interaction
- A product of variables that lets one slope depend on another variable.
Core formula
Use plain-language interpretation before algebra.
Example
M6_STARTUP_PREDICTION is a synthetic teaching dataset for comparing nonnested models. It is designed to practice nonnested comparison without presenting fabricated real-world empirical findings.
Interactive visual
Choose between two nonnested prediction models and explain which comparison criteria are legitimate.
Original Module 6 visual for Comparing Nonnested Models.
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
Comparing Nonnested Models Python example
Comparing Nonnested Models 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 5Add an intercept column to the regression design matrix.
- Line 6Add an intercept column to the regression design matrix.
- Line 7Display a result so students can inspect the output.
- Line 8Display a result so students can inspect the output.
- Line 9Display 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
NonnestedModelComparator
Compare nonnested models
Check whether model comparison is legitimate before choosing a specification.
Inputs
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 main mistake to avoid in Comparing Nonnested Models?
Quick quiz
What is the main mistake to avoid in Comparing Nonnested Models?
Quick quiz
Why is M6_HOUSING_LOGS a reasonable practice dataset here?
Key takeaway
Comparing Nonnested Models helps students make multiple regression more flexible while keeping interpretation precise and honest.