Monte Carlo Study of the Bias–Variance Tradeoff
This application accompanies the STA380 project by
Jizheng Huang, Victor Jiang, Tianchen Xu,
and
Kai Rui Zhu
(University of Toronto, Mississauga).
The goal of this project is to illustrate the bias-variance tradeoff in regression through repeated Monte Carlo simulation.
Users can explore how model flexibility, sample size, and noise level affect training MSE, test MSE, bias^2, and variance.
Simulation Framework
Data are generated according to the model
\( y = f(x) + \varepsilon \)
where \( f(x) \) is a known nonlinear function and
\( \varepsilon \sim \mathcal{N}(0, \sigma^2) \).
Monte Carlo simulation is used to estimate bias\(^2\),
variance, and MSE across model complexities.
For each Monte Carlo repetition, the app generates a new training sample, fits the selected regression model, and evaluates predictive performance.
Repeated fits are then used to estimate bias², variance, and mean squared error across model complexities.
How to Use the App
- Choose the simulation settings in the sidebar, including the random seed, sample size, noise level, model type, and model complexity.
- Adjust the number of Monte Carlo repetitions to control the stability of the estimates.
-
Click
Run Simulation
to generate updated results.
- Use the plot tabs to examine the bias-variance curves, prediction spread, and MSE decomposition table.
- Download the summary results if desired.
Interpretation
As model complexity increases, bias² typically decreases while variance increases.
This tradeoff often leads to a U-shaped test MSE curve, where overly simple models underfit and overly flexible models overfit.
The prediction spread plot shows how fitted models vary across Monte Carlo repetitions, while the decomposition table summarizes the average training MSE, test MSE, bias², and variance.
References
-
Hastie, T., Tibshirani, R., & Friedman, J. (2009).
The Elements of Statistical Learning.
Springer.
-
R Core Team (2024).
R: A Language and Environment for Statistical Computing.
-
R Core Team (2024).
shiny: Web Application Framework for R.
-
Voss, J. (2013).
An Introduction to Statistical Computing.
Wiley.