Skip to main content

Out-of-Sample R-Squared

IntermediateQuantitative FinanceAlso known as: machine learning in finance, Campbell Thompson, forecast evaluation, overfitting check, OOS R2

Finds: whether a forecasting model beats a simple benchmark on unseen data.

When to use it: Use it to judge whether a model really forecasts, as opposed to fitting history. It compares the model to a simple benchmark on data the model never saw. Positive means the model beats the benchmark. Return forecasts usually score a tiny positive number or a negative one, and even 0.5% a month can be economically useful, so judge it against the benchmark and costs, not against 100%.

The formula

ROS2\displaystyle R^{2}_{OS}=1−∑(rt−r^t)2∑(rt−rˉt)2\displaystyle =1-\frac{\sum(r_{t}-\hat{r}_{t})^{2}}{\sum(r_{t}-\bar{r}_{t})^{2}}

In words: Out-of-sample R-squared = 1 − (sum of squared errors of the model forecasts) / (sum of squared errors of a benchmark forecast, usually the historical average)

What each symbol means

r_tRealized returnpercent
r-hat_tModel forecast made before the return was knownpercent
r-bar_tBenchmark forecast, such as the average of past returnspercent

Worked example

Eight realized monthly returns, the model's forecasts made before each month, and a benchmark forecast of 0.5% a month are in the calculator.

Model squared errors0.000249
Benchmark squared errors0.001128
R-squared out of sample1 − 0.000249 ÷ 0.00112877.93%
Beats the benchmark? (11 if 0.779255>0 else 01
The answer

The model's squared errors sum to 0.000249 against 0.001128 for the benchmark, so the out-of-sample R-squared is 77.93%. The model 1.

Want every formula on a few pages?Get the free Cheat Sheet (PDF) →

Calculator

R-squared out of sample77.93%

Keep going