Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: bootstrp and bootci don't work if data inputs are not same length
Date: Wed, 11 Nov 2009 18:05:22 +0000 (UTC)
Organization: University of Vermont
Lines: 30
Message-ID: <hdeud2$h1l$1@fred.mathworks.com>
References: <hd2pt9$jnu$1@fred.mathworks.com> <hdej3j$pm2$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257962722 17461 172.30.248.37 (11 Nov 2009 18:05:22 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 11 Nov 2009 18:05:22 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 482243
Xref: news.mathworks.com comp.soft-sys.matlab:584299


Thank you, Peter.  I did notice afterwards the same-length constraint.  Your suggestion to run two bootstraps in parallel is helpful.  I ended up writing my own bootstrapping code to create the bootstat as a ratio of results from two vecs of different lengths, and then dovetailed the sub-functions for the bootci.

Peter Perkins <Peter.Perkins@MathRemoveThisWorks.com> wrote in message <hdej3j$pm2$1@fred.mathworks.com>...
> Alison wrote:
> > Has anyone made a workaround for this issue?   bootstrp documentation does not constrain the input data to same size
> 
> Sure it does:
> 
> >> help bootstrp
>  BOOTSTRP Bootstrap statistics.
>     BOOTSTAT = BOOTSTRP(NBOOT,BOOTFUN,D1,...) draws NBOOT bootstrap data
> [snip]
>     The third and later input arguments (D1,...) are data (scalars,
>     column vectors, or matrices) that are 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).  Scalar data are passed to BOOTFUN unchanged.
> 
> 
> >, but this error is thrown when passing in two vectors of different sizes (which should be fine, so long as the bootfun is designed to handle this):
> 
> BOOTSTRP is designed to support the following kind of bootstrapping:  The "data arguments" are thought of as a single set of data, comprising n observations on p variables (i.e., you pass in D1, D2, ... Dp, and they all have n rows).  Resample with replacement from the observation, i.e., generate n random integers drawn independently from the set 1:n, and use those to index into D1, D2, ... Dp, "in parallel".
> 
> BOOTSTRP accepting scalar arguments is just a convenience, to allow "tuning parameters" to be passed into your bootstrap function.  It actually pre-dates anonymous functions in MATLAB, which is what we encourage people to use these days.
> 
> > In case anyone is interested, the bootfun takes two vectors (each of whose elements contain only 1's and 0's), and computes a ratio of (sum1/length1) / (sum2/length2).
> 
> What you've described sounds equivalent to a stratified bootstrap, which is more general than what BOOTSTRP does.  It should be straight-forward for you to use BOOTSTRP as a starting point for your own function that allows that generality.  What you've described would presumably require _two_ resampling operations in parallel, not the one that BOOTSTRP is prepared to do.
> 
> Hope this helps.