Search code examples
matlabbioinformaticsphylogeny

Bootstrap a square matrix with Matlab


I want to understand how to bootstrap a square matrix with matlab. Any suggestions?


Solution

  • Bootstrap is sampling method. Main thing is that how do you sample the data.

    bootstat = bootstrp(nboot,bootfun,d1,...)
    [bootstat,bootsam] = bootstrp(...)
    bootstat = bootstrp(...,'Name',Value)
    

    The third and later input arguments (d1,...) are data (scalars, column vectors, or matrices) used to create inputs to bootfun. bootstrp creates each bootstrap sample by sampling with replacement from the rows of the non-scalar data arguments (these must have the same number of rows). bootfun accepts scalar data unchanged.

    As an example;

      [bootstat,bootsam] = bootstrp(4,...)
    

    returns n-by-4 matrix of bootstrap indices, bootsam. Each column in bootsam contains indices of the values that were drawn from the original data sets to constitute the corresponding bootstrap sample.

    Another example is ;

     load lawdata
     rng default  % For reproducibility
    [bootstatistics,bootsamples] = bootstrp(1000,@corr,lsat,gpa);
    

    Here bootstatistics is the (@corr) correlation statistics matrix and bootsamples is the bootstrap samples. lawdata has LSAT scores and GPAs 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 data