Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

 Quantlet: bootstrap Description: calculates from data vector x different bootstrap replications

 Usage: bx = bootstrap(x,nb,opt) Input: x n x 1 vector, data nb scalar, number of bootstrap replications opt string, option that defines the kind of bootstrap: "wild" - using golden section rule, "permut" - simple permutation, "naive" - naive bootstrap Output: bx n x nb matrix, bootstrap replications

Example:
library("stats")
randomize(4321)
n     = 100
x   = normal(n)			; generate normal data
bx  = bootstrap(x,200,"wild")	; wild bootstrap sample
"mean of data vector"
mean(x)				; mean of original data
"mean of wild bootstrap"
mean(mean(bx)')			; mean of wild bootstrap
bx  = bootstrap(x,200,"permut")
"mean of permutation bootstrap"
mean(mean(bx)')			; mean of permutations = mean of data
bx  = bootstrap(x,200,"naive")
"mean of naive bootstrap"
mean(mean(bx)')			; mean of naive bootstrap

Result:
Contents of _tmp
[1,] "mean of data vector"
Contents of mean
[1,]  0.17198
Contents of _tmp
[1,] "mean of wild bootstrap"
Contents of mean
[1,]  0.0049184
Contents of _tmp
[1,] "mean of permutation bootstrap"
Contents of mean
[1,]  0.17198
Contents of _tmp
[1,] "mean of naive bootstrap"
Contents of mean
[1,]  0.16547
Example:
library("stats")
randomize(4321)
n   = 100
x   = normal(n)								; generate normal data
bx  = bootstrap(x,200,"naive")
mubx = mean(bx)'							; mean of bootstrap samples
stdbx = sqrt(var(bx))'				; std. deviation of bootstrap samples
bxm = sqrt(n) *(mubx - mean(x)) / stdbx
bxm
; one may now plot a density of these values and calculate
; quantiles for confidence intervals

Result:
Only first and last five elements are shown:

Contents of bxm
[  1,]  -0.2676
[  2,] -0.47251
[  3,]  -1.1546
[  4,]     1.33
[  5,] -0.72827
...
[196,]   1.6301
[197,]   1.5728
[198,]  0.36706
[199,] -0.52581
[200,]  0.11956

Author: W. Haerdle, P. Cizek, 20021019 license MD*Tech
(C) MD*TECH Method and Data Technologies, 05.02.2006