Statistics Toolbox | ![]() ![]() |
Bootstrap statistics through resampling of data
Syntax
Description
draws bootstat = bootstrp(nboot,'
bootfun',d1,d2,...)
nboot
bootstrap samples from each of the input data sets, d1
, d2
, etc., and passes the bootstrap samples to function bootfun
for analysis. nboot
must be a positive integer, and each input data set must contain the same number of rows, n
. Each bootstrap sample contains n
rows chosen randomly (with replacement) from the corresponding input data set (d1
, d2
, etc.).
Each row of the output, bootstat
, contains the results of applying bootfun
to one set of bootstrap samples. If bootfun
returns multiple outputs, only the first is stored in bootstat
. If the first output from bootfun
is a matrix, the matrix is reshaped to a row vector for storage in bootstat
.
returns a matrix of bootstrap indices, [bootstat,bootsam] = bootstrap(...)
bootsam
. Each of the nboot
columns in bootsam
contains indices of the values that were drawn from the original data sets to constitute the corresponding bootstrap sample. For example, if d1
, d2
, etc., each contain 16 values, and nboot
=
4
, then bootsam
is a 16-by-4 matrix. The first column contains the indices of the 16 values drawn from d1
, d2
, etc., for the first of the four bootstrap samples, the second column contains the indices for the second of the four bootstrap samples, and so on. (The bootstrap indices are the same for all input data sets.)
Example
Correlate the LSAT scores and law-school GPA for 15 students. These 15 data points are resampled to create 1000 different data sets, and the correlation between the two variables is computed for each dataset.
load lawdata [bootstat,bootsam] = bootstrp(1000,'corrcoef',lsat,gpa); bootstat(1:5,:) ans = 1.0000 0.3021 0.3021 1.0000 1.0000 0.6869 0.6869 1.0000 1.0000 0.8346 0.8346 1.0000 1.0000 0.8711 0.8711 1.0000 1.0000 0.8043 0.8043 1.0000 bootsam(:,1:5) ans = 4 7 5 12 8 1 11 10 8 4 11 9 12 4 2 11 14 15 5 15 15 13 6 6 2 6 8 4 3 8 8 2 15 8 6 13 10 11 14 5 1 7 12 14 14 1 11 10 1 8 8 14 2 14 7 11 12 10 8 15 1 4 14 8 1 6 1 5 5 12 2 12 7 15 12 hist(bootstat(:,2))
The histogram shows the variation of the correlation coefficient across all the bootstrap samples. The sample minimum is positive, indicating that the relationship between LSAT score and GPA is not accidental.
![]() | binostat | boxplot | ![]() |