Bootstrap PDF
Bootstrap PDF
1 / 24
Agenda
I Re-sampling Methods
I Cross Validation
I The Bootstrap
2 / 24
Re-sampling Methods
3 / 24
Re-sampling Methods
4 / 24
The Bootstrap
5 / 24
The Bootstrap
6 / 24
Toy example: Investing
7 / 24
Toy example: Investing
8 / 24
Toy example: Investing
One can show (exercise) that the value that minimizes the risk is
given by
σY2 − σXY
α= , (1)
σY2 + σX2 − 2σXY
9 / 24
Toy example: Investing
σ̂Y2 − σ̂XY
α̂ = , (2)
σ̂Y2 + σ̂X2 − 2σ̂XY
10 / 24
Toy example: Investing
11 / 24
The Bootstrap
12 / 24
The Boostrap
13 / 24
The Boostrap (continued)
I This procedure is repeated B times for some large value of B,
in order to produce B different bootstrap data sets,
Z ∗1 , Z ∗2 , . . . , Z ∗B .
16 / 24
The Boostrap on the Portfolio data set
The Portfolio data set in the ISLR package is the investment data
set that motivated the bootstrap earlier.
To illustrate the use of the bootstrap on this data, we must
17 / 24
The Boostrap on the Portfolio data set
library(ISLR)
alpha.fn=function(data,index){
X=data$X[index]
Y=data$Y[index]
return((var(Y)-cov(X,Y))/(var(X)+var(Y)-2*cov(X,Y)))
}
alpha.fn(Portfolio , 1:100)
## [1] 0.5758321
18 / 24
The Boostrap on the Portfolio data set
set.seed (1)
alpha.fn(Portfolio,sample(100,100,replace=T))
## [1] 0.5963833
19 / 24
Implementing the Bootstrap
20 / 24
Implementing the Bootstrap
library(boot)
21 / 24
Implementing the Bootstrap
# produce R=1000 bootstrap estimates
# for alpha using boot()
boot(Portfolio, alpha.fn, R=1000)
##
## ORDINARY NONPARAMETRIC BOOTSTRAP
##
##
## Call:
## boot(data = Portfolio, statistic = alpha.fn, R = 1000)
##
##
## Bootstrap Statistics :
## original bias std. error
## t1* 0.5758321 -7.315422e-05 0.08861826
22 / 24
Bootstrap Summary Results
The final output shows that using the original data, α̂ = 0.5758,
and that the bootstrap estimate for SE(α̂) is 0.0886.
23 / 24
Bootstrap: Other Applied Examples with R
24 / 24