01 / 21

Model Selection
& Overfitting

Learn how to choose the right model complexity for biological data and avoid the trap of fitting noise instead of signal.

Biostatistics

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.

Simple Model
A straight line: \( y = \beta_0 + \beta_1 x \). Easy to interpret, may miss patterns.
Complex Model
A high-degree polynomial: \( y = \beta_0 + \beta_1 x + \cdots + \beta_k x^k \). Flexible, but risky.

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.

Predictor (e.g., drug dose) Response True signal Observed data (signal + noise)

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.

Overfit model (degree 14) Simple model (degree 1)

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.

High Bias
An underfit model makes strong assumptions that don't match reality, leading to systematic errors.
High Variance
An overfit model is overly sensitive to the specific training data, changing drastically with new samples.

The Bias-Variance Tradeoff

Every model's prediction error can be decomposed into three parts. This decomposition is the foundation of model selection:

Model Complexity Error Optimal Underfit Overfit Bias² Variance Total Error

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).

Model Complexity Error Gap Best Training error Test error

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:

AIC
\( \text{AIC} = -2\ln(\hat{L}) + 2k \)
Penalizes by 2 per parameter. Better for prediction.
BIC
\( \text{BIC} = -2\ln(\hat{L}) + k\ln(n) \)
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.

Test Train Train Train Train 1 Train Test Train Train Train 2 Train Train Test Train Train 3 Train Train Train Test Train 4 Train Train Train Train Test 5

How to Select a Model

1
Define candidate models. Start with simple (e.g., linear) and add complexity incrementally (quadratic, cubic, etc.).
2
Split your data. Hold out a test set (20-30%) or use \( k \)-fold cross-validation.
3
Fit each model on the training data and evaluate on the test/validation set.
4
Compare using criteria: lowest test error, lowest AIC/BIC, or best cross-validation score.
5
Choose the simplest model whose performance is close to the best. When in doubt, prefer parsimony.

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:

5 Predictors
\( R^2 = 0.82 \)
\( R^2_{\text{adj}} = \) 0.79
6 Predictors
\( R^2 = 0.83 \)
\( 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:

Model CV Error Linear Cubic Degree 8 0 50 100 150 98 72 134

Common Mistakes

✕ Using Training Error Alone
Training error always improves with more parameters. It never reveals overfitting: you must check test error.
✕ Ignoring Sample Size
A model with 20 parameters on 25 data points will overfit. Rule of thumb: need at least 10-20 observations per parameter.
✕ Data Leakage
Using test data during training (e.g., normalizing with full dataset statistics) creates falsely optimistic results.

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?