A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Cross-Validation and Out-of-Sample Model Evaluation

College Depth 114 in the knowledge graph ☐ I know this ☆ Set as goal
1topic build on this
583prerequisites beneath it
See this on the map →
Multiple RegressionR-Squared and Model Fit→→Prediction Intervals and Out-of-Sample Forecasting
cross-validation out-of-sample model-evaluation

Core Idea

K-fold and leave-one-out cross-validation assess out-of-sample predictive performance by iteratively holding out data, fitting on the remainder, and testing on the holdout. This prevents overfitting and provides honest estimates of generalization error.

Explainer

You already know that R² measures how well a regression fits the data in your sample. The problem is that R² is measured on the same data used to estimate the model — and any model, no matter how badly specified, can be made to fit better simply by adding more variables. A model with as many parameters as observations will have R² = 1.0 while predicting new data no better than random noise. This pathology is called overfitting: the model has learned the quirks of your particular sample rather than the underlying pattern.

Cross-validation is the solution. The core idea is to simulate what happens when you use the model on new data — by actually withholding some data during estimation and testing the model on what it never saw. In k-fold cross-validation, you divide the dataset into k roughly equal groups (folds). You train the model on k−1 folds, then measure prediction error on the held-out fold. Repeat this k times, each time holding out a different fold. The average prediction error across all k held-out folds is your cross-validation error — an honest estimate of how well the model generalizes. With k = n (one observation held out each time), you get leave-one-out cross-validation (LOOCV), the most thorough variant but computationally expensive.

The key insight is what this procedure reveals that in-sample R² hides. Suppose you compare a simple 3-variable model to a complex 15-variable model. In-sample, the 15-variable model almost always wins on R². But out-of-sample, the simpler model often wins — because the extra variables in the complex model were fitting noise specific to your sample. Cross-validation penalizes this complexity automatically: models that overfit perform well on training folds but poorly on the held-out fold, which drags down the average CV error.

Cross-validation also provides a disciplined method for model selection. When choosing between competing specifications — different sets of regressors, different functional forms, or different regularization strengths — pick the model with the lowest cross-validation error rather than the highest in-sample R². This connects directly to your earlier understanding of R²: a high R² tells you how well the model describes the past; a low CV error tells you how well the model predicts the future. In causal economic research, you often care more about unbiased estimates than prediction, but in forecasting applications — GDP growth, asset prices, demand — cross-validated predictive performance is the primary scorecard.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Dividing Integers → Unit Rates → Proportions → Percent Concept → Converting Between Fractions, Decimals, and Percents → Operations with Rational Numbers → Two-Step Equations → Solving Multi-Step Equations → Equations with Variables on Both Sides → Angle Pairs: Complementary, Supplementary, and Vertical → Parallel Lines and Transversals → Corresponding Angles → Alternate Interior Angles → Triangle Angle Sum Theorem → Exterior Angle Theorem → Triangle Inequality Theorem → Similar Triangles: AA Similarity → Similar Triangles: SSS and SAS Similarity → Proportions in Similar Triangles → Right Triangle Trigonometry Introduction → Sine, Cosine, and Tangent Ratios → Trigonometric Ratios Review → Radian Measure → Converting Between Degrees and Radians → The Unit Circle → Graphing Sine and Cosine → Graphing Tangent and Reciprocal Trigonometric Functions → Derivatives of Trigonometric Functions → Antiderivatives → Indefinite Integrals → Basic Integration Rules → Riemann Sums → Definite Integral Definition → Probability Density Functions and Continuous Distributions → Cumulative Distribution Functions → Continuous Random Variables → Probability Density Functions → Expected Value → Weak Law of Large Numbers → Probability Axioms and Rules → Conditional Probability → Independence of Events → Sampling Distributions → Standard Error of Estimators → Hypothesis Testing: Framework and Logic → P-values and Statistical Significance → Effect Size and Practical Significance → Hypothesis Testing: Framework and Logic → Z-Tests and T-Tests for Means → One-Sample Z-Test for Means → One-Sample and Two-Sample T-Tests → Inference in Linear Regression → Prediction Intervals in Regression → Linear Regression Basics → Residuals and Goodness of Fit (R²) → Simple (Bivariate) OLS Regression → Classical OLS Assumptions (Gauss-Markov) → Multiple Regression → Interpreting Regression Coefficients → Hypothesis Testing in Regression → F-Test and Joint Significance → R-Squared and Model Fit → Cross-Validation and Out-of-Sample Model Evaluation

Longest path: 115 steps · 583 total prerequisite topics

Prerequisites (2)

Leads To (1)