Model Selection
& Overfitting
Learn how to choose the right model complexity for biological data and avoid the trap of fitting noise instead of signal.
What Is a Statistical Model?
A statistical model is a mathematical equation that describes the relationship between variables in your data. In biostatistics, we use models to predict outcomes like disease risk, drug response, or population growth.
Signal vs. Noise
Every biological dataset contains two components: the true underlying pattern (signal) and random variation (noise) from measurement error, biological variability, or sampling.
What Is Overfitting?
Overfitting occurs when a model learns the noise in the training data rather than the underlying pattern. The model performs excellently on the data it was trained on but fails badly on new, unseen data.
What Is Underfitting?
Underfitting is the opposite problem: the model is too simple to capture the real pattern. It ignores important structure in the data and performs poorly on both training and test data.
The Bias-Variance Tradeoff
Every model's prediction error can be decomposed into three parts. This decomposition is the foundation of model selection:
Training vs. Test Error
The key diagnostic for overfitting: compare how well your model performs on data it has already seen (training) versus data it has never seen (test).
Overfitting vs. Underfitting
| Overfitting | Underfitting | |
|---|---|---|
| Complexity | Too many parameters | Too few parameters |
| Training error | Very low | High |
| Test error | High | High |
| Bias | Low | High |
| Variance | High | Low |
| Diagnosis | Big gap: train vs. test | Both errors are high |
| Fix | Simplify model, add data | Add features, use complex model |
Model Selection Criteria
Statisticians have developed formal tools that balance fit and complexity. Two of the most important are AIC and BIC:
Penalizes by 2 per parameter. Better for prediction.
Heavier penalty when \( n \) is large. Prefers simpler models.
Cross-Validation: The Gold Standard
Cross-validation directly estimates how well a model will perform on new data by repeatedly splitting the data into training and validation sets.
How to Select a Model
Example 1: Polynomial Degree
A researcher models the relationship between patient age (\( x \)) and blood pressure (\( y \)) using polynomials of degree 1, 3, and 10. With \( n = 30 \) patients:
| Model | Train MSE | Test MSE | AIC |
|---|---|---|---|
| Degree 1 (linear) | 124 | 131 | 198 |
| Degree 3 (cubic) | 78 | 89 | 172 |
| Degree 10 | 12 | 245 | 310 |
Example 2: Adjusted \( R^2 \)
Ordinary \( R^2 \) always increases when you add predictors, even useless ones. Adjusted \( R^2 \) penalizes for extra parameters:
A study predicts tumor size from clinical variables. Adding a 6th irrelevant predictor:
\( R^2_{\text{adj}} = \) 0.79
\( R^2_{\text{adj}} = \) 0.78
Example 3: Cross-Validation in Practice
A biostatistician compares three models for predicting disease progression using 5-fold CV on \( n = 200 \) patients:
Common Mistakes
Model Selection Tools Compared
| AIC | BIC | Cross-Validation | |
|---|---|---|---|
| Based on | Likelihood + penalty | Likelihood + penalty | Repeated train/test split |
| Penalty strength | \( 2k \) | \( k \ln(n) \) | Implicit (data-driven) |
| Favors | Predictive accuracy | Simpler models | Generalization |
| Needs held-out data? | No | No | Yes (via folds) |
| Computational cost | Low | Low | Higher |
| Best for | Quick screening | Identifying true model | Final model selection |
Question 1 of 5
A model has very low training error but much higher test error. This is a sign of:
Question 2 of 5
In the bias-variance tradeoff, increasing model complexity generally:
Question 3 of 5
A researcher compares two models: Model A has \( \text{AIC} = 245 \) and Model B has \( \text{AIC} = 212 \). Which is preferred?
Question 4 of 5
In 5-fold cross-validation, each data point is used as part of the test set:
Question 5 of 5
Adding a 6th predictor to a regression model increased \( R^2 \) from 0.82 to 0.83 but decreased \( R^2_{\text{adj}} \) from 0.79 to 0.78. What should you do?