No BSD License  

Highlights from
Bootstrap a statistic in a grouped sample

image thumbnail
bstrag_demo
function bstrag_demo
% BSTRAG_DEMO Demonstration of BSTRAG and BSTATS
% EXAMPLE   : bstrag_demo (Oh, the FEX code metrics..)  
% AUTHOR    : Dimitri Shvorob, dimitri.shvorob@vanderbilt.edu, 3/25/07

n = 100;
x = randn(n,1);                   % random normal sample 
c = unidrnd(2,n,1);               % arbitrarily split into two groups of roughly equal size (p = 0.5)

B = 1000;                         % number of bootstrap samples

res = bstrag(B,'meandiff_scalar',c,x);     % one run; fun output in a vector
class(res)
size(res)

disp('Between-groups mean difference: sample value, bootstraped variance, two-sided 95% confidence interval')
  
[m,v,cil,ciu] = bstats(res)       %#ok
                                  
                              
res = bstrag(B,'meandiff_structure',c,x);  % another run; fun output in a structure
class(res)
size(res)

[m,v,cil,ciu] = bstats(res,'d')   %#ok
                                 

d = [res.d];                      % values of d in bootstrap samples
f = figure;
opt.dx   = .025;
opt.xmin = -1;
opt.xmax =  1;
opt.xmrk =  0; 
histw(d,opt)
title({'Between-groups mean difference: bootstrap distribution', ...
       '\itx_{i} ~ N\rm[\it0,1\rm], \iti = 1,..,100; B = 1000 \rmbootstrap samples'})
print(f,'-djpeg','bstrag_demo')     

Contact us at files@mathworks.com