| Statistics Toolbox | Search  Help Desk |
| bootstrp | Examples |
Bootstrap statistics through resampling of data.
Syntax
bootstat = bootstrp(nboot,'bootfun',d1,...)[bootstat,bootsam] = bootstrp(...)
Description
bootstrp(nboot,'bootfun',d1,...) draws nboot bootstrap data samples and analyzes them using the function bootfun. nboot must be a positive integer. bootstrp passes the data d1, d2, etc., to bootfun.
[bootstat,bootsam] = bootstrap(...) returns the bootstrap statistics in bootstat. Each row of bootstat contains the results of applying 'bootfun' to one bootstrap sample. If 'bootfun' returns a matrix, then this output is converted to a long vector for storage in bootstat. bootsam is a matrix of indices into the rows of the data matrix.
Example
Correlate the LSAT scores and and law-school GPA for 15 students. These 15 data points are resampled to create 1000 different datasets, 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 and GPA is not accidental.