Bootstrapping Estimates of
the CER Model
Econ 424/Amath 462
Eric Zivot
Summer 2013
Updated: July 23, 2013

© Eric Zivot 2006

Data for Examples-0.2
0.0-0.05 00.00 0.05 0.10
-0.4
-0.15

sp500

-0.2

msft

0.2
0-0.4

sbux
s

0.0

0.2

returns.z

1993

1994

1995

1996

1997

1998

1999

2000

Index

T = 100 months© Eric Zivot 2006

Estimated Standard Errors> se.muhat = sigmahat.vals/sqrt(nobs)> rbind(muhat.vals,se.muhat)
sbux
msft
sp500
p
muhat.vals
0.02770.02750.01253
se.muhat0.0135
0.01060.00378> se.sigma2hati2h= sigma2hat.vals/sqrt(nobs/2)i2hl /( b /2)> rbind(sigma2hat.vals,se.sigma2hat)
sbux
msft
sp500
sigma2hat.vals
0.018450.011410.00143
se.sigma2hat
0.002610.001610.00020g= sigmahat.vals/sqrt(2*nobs)g/ q ()> se.sigmahat> rbind(sigmahat.vals,se.sigmahat)
sbux
msft
sp500
sigmahat.valsg0.13580.10680.0378se.sigmahat
0.00960.00750.0026© Eric Zivot 2006R function sample()p ()# random permutations of the index vector 1:5> sample(5)[1] 1 3 2 5 4> sample(5)[1] 4 2 3 5 1# random sample of size 5 from MSFT return withreplacement> sample(MSFT, 5, replace=TRUE)[1] -0.02904 0.12130 -0.01890 -0.15332 -0.14627© Eric Zivot 2006

Brute Force Bootstrap
Same idea as Monte Carlo Simulation but instead ofgenerating random data from an assumed distribution
distribution,
you generate random data by sampling with replacementfrom the observed data
# bootstrap distribution for ˆ> B = 999 # why use 999?
> muhat.boot = rep(0, B)> nobs = length(MSFT)> for (i in 1:B) {+ boot.data = sample(MSFT, nobs, replace=TRUE)+ muhat.boot[i] = mean(boot.data)}© Eric Zivot 2006

Brute Force Bootstrap# bootstrap bias
> mean(muhat.boot) - muhat.MSFT[1] -0.0005643# bootstrapp SE> sd(muhat.boot)[1] 0.01045

Bootstrap SE is very closet analytictol ti SE# analytic SE> sigmahat.MSFT/sqrt(length(MSFT))[1] 0.01068© Eric Zivot 2006

Brute Force Bootstrap
Normal Q-Q Plot

0.0
40.0
30.0
10.02SampleQ
uantiles

10000.0050F
requenc
y

1
500.0
5200

Histogram of muhat.boot

-0.01

0.01

0.03

0.05

muhat.boot-3-2-10

12Theoretical Quantiles

par(mfrow=c(1,2))pa(o c( , ))hist(muhat.boot, col="slateblue1")
abline(v=muhat.MSFT, col="white", lwd=2)
qqnorm(muhat.boot)qqline(muhat.boot)li ( h t b t)par(mfrow=c(1,1))© Eric Zivot 2006

3

R Package boot• Implements a variety of bootstrapping functions• Background material is book by Davidson andHinkley, Bootstrap Methods and Their
A li ti
Application,
C b id U
Cambridge
Universityiit P
Press, 1997
1997.
• Main functions are:– boot()
b t()
b t t
bootstrap
user suppliedli d ffunction
ti– boot.ci() compute bootstrap confidencei tintervall© Eric Zivot 2006

Example: Bootstrapping sample mean
# function for bootstrapping sample mean
mean.boot = function(x, idx) {# arguments:# x
data to be resampled# ididxvector
ector of scrambled indices created#by boot() function# value:# ansmean value computed using resampled#data
ans = mean(x[idx])
ans}© Eric Zivot 2006

Example: Bootstrapping sample mean
> MSFT.mean.boot = boot(MSFT, statistic = mean.boot, R=999)> class(MSFT.mean.boot)[1] "b"boot“
t“
Number of bootstrap samples> MSFT.mean.boot
ORDINARY NONPARAMETRIC BOOTSTRAP

Call:boot(data = MSFT, statistic = mean.boot, R = 999)

Bootstrap Statistics :originalbias
t1*
0.02756-0.00013
Sample mean

std. error
0.01052

Bootstrap estimate ofbias© Eric Zivot 2006

Bootstrap estimate of SE

0.02 0.03 0.04 0.05
-00.01 0.00 0.01t*20100Density

30

0.06

40

Histogram of t

0.00

0.04

-3

t*

-1

1

2

3

Quantiles of Standard Normal> plot(MSFT.mean.boot)© Eric Zivot 2006

Compare Bootstrap Statistics with Analytic Formulas
ORDINARY NONPARAMETRIC BOOTSTRAP

Call:boot(data = MSFT, statistic = mean.boot, R = 999)

Bootstrap Statistics :original
bias
t1*
t1
0.02756-0.00013
0.00013std. error
0.01052# compare boot SE with analytic SE> se.muhat.MSFT = sigmahat.MSFT/sqrt(length(MSFT))> se.muhat.MSFT
h t S[1] 0.01068© Eric Zivot 2006

Bootstrap Confidence Intervals> bootboot.ci(MSFT.mean.boot,ci(MSFT mean boot conf = 00.95,95 type =+c("norm","perc"))
BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
Based on 999 bootstrap replicates
CALL :
boot.ci(boot.out = MSFT.mean.boot, conf = 0.95, type =c("norm",c(norm , "perc"))
perc ))
Intervals :Level
NormalPercentile95%( 00.0071,0071
00.04830483 )( 00.0065,0065
00.04710471 )Calculations and Intervals on Original Scale© Eric Zivot 2006

Example: Bootstrapping Sample SD# function for bootstrapping sample standard deviation
sd.boot = function(x, idx) {# arguments:# x
data to be resampled# idx
vector of scrambled indices created by#b t() fboot()functionti# value:# ans
sd value computed using resampled data
ans = sd(x[idx])
ans}© Eric Zivot 2006

Example: Bootstrapping Sample SD> MSFT.sd.boot = boot(MSFT, statistic = sd.boot, R=999)> MSFT.sd.boot
ORDINARY NONPARAMETRIC BOOTSTRAP

Call:boot(data = MSFT, statistic = sd.boot, R = 999)

Bootstrap Statistics :original
bias
t1* 0.1068-0.00145

std. error
0.01078# compare boot SE with analytic SE based on CLT> se.sigmahat.MSFT = sigmahat.MSFT/sqrt(2*length(MSFT))g> se.sigmahat.MSFT[1] 0.00755© Eric Zivot 2006

0.12
0.11
0.09

0.10

t*200.08

100Densitty

30

0.13

400.14

Histogram of t

0.08

0.12

-3

tt*-1

123

Quantiles of Standard Normal> plot(MSFT.sd.boot)© Eric Zivot 2006

Example: Boostrapping Normal VaR
ValueAtRisk.boot = function(x, idx, p=0.05, w=100000) {# x.matt
d t t
data
to b
be resampled
l d
# idx
vector of scrambled indices created by#boot() function# pprobability value for VaR calculation# w
value of initial investment# value:# ans
Value-at-Risk
Valueat Risk computed using resampled dataq = mean(x[idx]) + sd(x[idx])*qnorm(p)VaR = (exp(q) - 1)*w
VaR}

© Eric Zivot 2006

Example: Boostrapping Normal VaR> MSFT.VaR.boot
ORDINARY NONPARAMETRIC BOOTSTRAP

Call:
Cll
boot(data = MSFT, statistic = ValueAtRisk.boot, R = 999)

Bootstrap Statistics :original
bias
t1* -13769.40 210.2801

Samplep VaR estimatestd. error
1886.953

Bootstrap SE© Eric Zivot 2006

-12000
t*--16000

0.00010-200000.00000

Densitty

0.00020

Histogram of t-20000-14000-8000

tt*-3-112

3

Quantiles of Standard Normal> plot(MSFT.VaR.boot)© Eric Zivot 2006

Example: Boostrapping Normal VaR> boot.ci(MSFT.VaR.boot, conf=0.95, type=c("norm", "perc"))
BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
Based on 999 bootstrap replicates
CALL :
boot.ci(boot.out = MSFT.VaR.boot, conf = 0.95, type =c("norm", "perc"))
Intervals :Level
Normal95%(-17678, -10281 )ˆ  2  SEboot (ˆ)Percentile(-17212, -10009 )**[ q.025, q.975]© Eric Zivot 2006