Statistics and Regression, lesson 10
The bootstrap
Resampling your data to see how sure you should be.
A Sharpe ratio, a median or a model's test score has no simple formula for its standard error. The bootstrap gets one from your data alone, by drawing new samples from the one you have. You need standard errors from Samples and estimates, and intervals from Confidence intervals.
By the end, you can:
Part 1. Resample your own data
Build bootstrap resamples and read a standard error from them.
For an average there's a formula, s / √n. Most numbers you'd want error bars on don't have one. The bootstrap needs no formula, so start where you can check it: five months of a simulated strategy.
Example 1.1
Five months, resampled
A strategy returned −4%, 0%, 2%, 4% and 8% over five months, an average of 2%. How far would the average of five other months typically land from it?
- Draw one resample8, 0, 8, −4, 2 → average 2.8
Pick one of the five months at random, put it back, and repeat until you have five. Some months come twice, some not at all.
- Draw them all5⁵ = 3,125 resamples
Each of five picks can be any of five months. A computer usually draws a few thousand. Here you can list them all.
- Measure their spreadsd of the 3,125 averages = 1.79
It stands in for how far another five months' average lands.
- Check it by hand√(80 / 5) / √5 = 4 / 2.24 = 1.79
The squared distances from 2% add to 80, so one pick has a spread of √(80 / 5) = 4. An average of five moves √5 times less.
- Compare the formulas / √n = √(80 / 4) / √5 = 2.0
The formula divides by n − 1, so on tiny samples the bootstrap runs a little narrow.
AnswerAbout 1.8 points, close to the formula's 2.0.
You can't draw five new months from the market. The bootstrap treats your five as the best picture of the market you have, and draws from that instead. If the picture is fair, resamples vary the way new samples would.
The bootstrap
Estimating how much a number would vary by recomputing it on many resamples: datasets the same size as yours, drawn from it with replacement, so each pick goes back before the next. The spread of the results is the bootstrap standard error.
average of n picks: √(Σ(x − x̄)² / n) / √n = 4 / √5 = 1.79
Two rules make it work. Each resample has as many points as your data, because an average's wobble depends on n. And each pick goes back: without that, every resample is your data reshuffled, and its average never moves.
Your turn
Four days returned 1%, 3%, 5% and 7%. With every possible resample drawn, what bootstrap standard error does their average get?
Part 2. Intervals with no formula
Read a percentile bootstrap interval for a Sharpe ratio.
Keep going with Pro
You've done the first part. Pro opens the rest of this lesson, and every other one.
- Intervals with no formula
- When resampling breaks
Statistics and Regression overviewSpotted a mistake? Tell us.