Path: news.mathworks.com!not-for-mail
From: Peter Perkins <Peter.Perkins@MathRemoveThisWorks.com>
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 09:52:34 -0500
Organization: The MathWorks, Inc.
Lines: 27
Message-ID: <hdej3j$pm2$1@fred.mathworks.com>
References: <hd2pt9$jnu$1@fred.mathworks.com>
NNTP-Posting-Host: perkinsp.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1257951155 26306 172.31.57.88 (11 Nov 2009 14:52:35 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 11 Nov 2009 14:52:35 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
In-Reply-To: <hd2pt9$jnu$1@fred.mathworks.com>
Xref: news.mathworks.com comp.soft-sys.matlab:584216


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.