When using bootstrp, are paired variables resampled together?
4 views (last 30 days)
Show older comments
In looking at the example for bootstrp in the documentation, two variables include lsat and gpa (<http://www.mathworks.com/help/stats/bootstrp.html)>. Do the values for these variables stay paired (the data points are resampled versus each variable is resampled separately)? For instance, if a person has an LSAT score of 115 and a GPA of 3.6, when that data point is resampled subsequently, will 115 and 3.6 stay paired, or are the two variables resampled independently?
0 Comments
Answers (1)
Aditya
on 8 Feb 2025
Hi Macrina,
In the bootstrp function in MATLAB, when you resample data that consists of paired observations (like LSAT scores and GPA), the values stay paired during the resampling process. This means that if you have a data point where someone has an LSAT score of 115 and a GPA of 3.6, these two values will remain together as a single observation when resampled.
The bootstrp function is used to perform bootstrapping, which involves resampling with replacement from the original dataset to create many simulated samples. When you pass a matrix of data to bootstrp, each row of the matrix is treated as a single observation, and these rows are resampled as whole units. Thus, the relationship between the variables in each row is preserved.
Example code:
% Sample data: LSAT and GPA
data = [115, 3.6; 120, 3.8; 110, 3.5; 130, 3.9];
% Define a function to compute the mean of each column
meanFunc = @(x) mean(x);
% Use bootstrp to resample the data
numBootstrapSamples = 1000;
bootstrapResults = bootstrp(numBootstrapSamples, meanFunc, data);
% Each row in bootstrapResults corresponds to a bootstrap sample
% The first column is the mean LSAT, the second column is the mean GPA
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!