Table of contents

  1. The jackknife
  2. The bootstrap principle
  3. The bootstrap

The jackknife


The jackknife


The jackknife


Continued


Example


Example

The gist of the code

n <- length(gmVol)
theta <- median(gmVol)
jk <- sapply(1 : n,
             function(i) median(gmVol[-i])
             )
thetaBar <- mean(jk)
biasEst <- (n - 1) * (thetaBar - theta) 
seEst <- sqrt((n - 1) * mean((jk - thetaBar)^2))

Example

Or, using the bootstrap package

library(bootstrap)
out <- jackknife(gmVol, median)
out$jack.se
out$jack.bias

Example


Pseudo observations


The bootstrap


The bootstrap principle


The bootstrap in practice


Example



Example code

B <- 1000
n <- length(gmVol)
resamples <- matrix(sample(gmVol,
                           n * B,
                           replace = TRUE),
                    B, n)
medians <- apply(resamples, 1, median)
sd(medians)
[1] 3.148706
quantile(medians, c(.025, .975))
    2.5%    97.5% 
582.6384 595.3553 


Notes on the bootstrap


library(boot)
stat <- function(x, i) {median(x[i])}  
boot.out <- boot(data = gmVol,
                 statistic = stat,
                 R = 1000)
boot.ci(boot.out)
Level     Percentile            BCa          
95%   (583.1, 595.2 )   (583.2, 595.3 )