<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265218</link>
    <title>MATLAB Central Newsreader - bootstrp and bootci don't work if data inputs are not same length</title>
    <description>Feed for thread: bootstrp and bootci don't work if data inputs are not same length</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sat, 07 Nov 2009 03:35:05 -0500</pubDate>
      <title>bootstrp and bootci don't work if data inputs are not same length</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265218#692842</link>
      <author>Alison </author>
      <description>Has anyone made a workaround for this issue?   bootstrp documentation does not constrain the input data to same size, 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):&lt;br&gt;
&lt;br&gt;
??? Index exceeds matrix dimensions.&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt; bootstrp at 114&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tmp = feval(bootfun,X1(onesample,:),X2(onesample,:));&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Looking at bootstrp line 114, the cause is clear:&lt;br&gt;
&lt;br&gt;
onesample (a set of n indices randomly generated over [1,n]) is generated once, and then used to index into all data vectors passed into bootstrp (ugh).  However, n is defined as the max length of all varargin, so indexing into the shorter data vector(s) will throw the error.&lt;br&gt;
&lt;br&gt;
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).&lt;br&gt;
&lt;br&gt;
Thank you for the help!</description>
    </item>
    <item>
      <pubDate>Wed, 11 Nov 2009 14:52:34 -0500</pubDate>
      <title>Re: bootstrp and bootci don't work if data inputs are not same length</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265218#693874</link>
      <author>Peter Perkins</author>
      <description>Alison wrote:&lt;br&gt;
&amp;gt; Has anyone made a workaround for this issue?   bootstrp documentation does not constrain the input data to same size&lt;br&gt;
&lt;br&gt;
Sure it does:&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; help bootstrp&lt;br&gt;
&amp;nbsp;BOOTSTRP Bootstrap statistics.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;BOOTSTAT = BOOTSTRP(NBOOT,BOOTFUN,D1,...) draws NBOOT bootstrap data&lt;br&gt;
[snip]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The third and later input arguments (D1,...) are data (scalars,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;column vectors, or matrices) that are used to create inputs to BOOTFUN.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;BOOTSTRP creates each bootstrap sample by sampling with replacement&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;from the rows of the non-scalar data arguments (these must have the&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;same number of rows).  Scalar data are passed to BOOTFUN unchanged.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt;, 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):&lt;br&gt;
&lt;br&gt;
BOOTSTRP is designed to support the following kind of bootstrapping:  The &quot;data arguments&quot; 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, &quot;in parallel&quot;.&lt;br&gt;
&lt;br&gt;
BOOTSTRP accepting scalar arguments is just a convenience, to allow &quot;tuning parameters&quot; 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.&lt;br&gt;
&lt;br&gt;
&amp;gt; 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).&lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
&lt;br&gt;
Hope this helps.</description>
    </item>
    <item>
      <pubDate>Wed, 11 Nov 2009 18:05:22 -0500</pubDate>
      <title>Re: bootstrp and bootci don't work if data inputs are not same length</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265218#693957</link>
      <author>Alison </author>
      <description>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.&lt;br&gt;
&lt;br&gt;
Peter Perkins &amp;lt;Peter.Perkins@MathRemoveThisWorks.com&amp;gt; wrote in message &amp;lt;hdej3j$pm2$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Alison wrote:&lt;br&gt;
&amp;gt; &amp;gt; Has anyone made a workaround for this issue?   bootstrp documentation does not constrain the input data to same size&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Sure it does:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; help bootstrp&lt;br&gt;
&amp;gt;  BOOTSTRP Bootstrap statistics.&lt;br&gt;
&amp;gt;     BOOTSTAT = BOOTSTRP(NBOOT,BOOTFUN,D1,...) draws NBOOT bootstrap data&lt;br&gt;
&amp;gt; [snip]&lt;br&gt;
&amp;gt;     The third and later input arguments (D1,...) are data (scalars,&lt;br&gt;
&amp;gt;     column vectors, or matrices) that are used to create inputs to BOOTFUN.&lt;br&gt;
&amp;gt;     BOOTSTRP creates each bootstrap sample by sampling with replacement&lt;br&gt;
&amp;gt;     from the rows of the non-scalar data arguments (these must have the&lt;br&gt;
&amp;gt;     same number of rows).  Scalar data are passed to BOOTFUN unchanged.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;, 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):&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; BOOTSTRP is designed to support the following kind of bootstrapping:  The &quot;data arguments&quot; 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, &quot;in parallel&quot;.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; BOOTSTRP accepting scalar arguments is just a convenience, to allow &quot;tuning parameters&quot; 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.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; 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).&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 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.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Hope this helps.</description>
    </item>
    <item>
      <pubDate>Thu, 21 Jan 2010 17:34:06 -0500</pubDate>
      <title>Re: bootstrp and bootci don't work if data inputs are not same length</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265218#710229</link>
      <author>chris </author>
      <description>just incase anyone thought the documentation could have poss been a tiny bit better for matlabs bootstrapping:&lt;br&gt;
&lt;br&gt;
x = normrnd(10,2,100,1);&lt;br&gt;
ci = bootci(1000,@nanmean,x);  %my conf limits (95%)&lt;br&gt;
[bootstat,bootsam] = bootstrp(1000,@nanmean,x);&lt;br&gt;
mymean = mean(bootstat);&lt;br&gt;
&lt;br&gt;
also of interest:&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.csp.curtin.edu.au/downloads/bootstrap_toolbox.html&quot;&gt;http://www.csp.curtin.edu.au/downloads/bootstrap_toolbox.html&lt;/a&gt; </description>
    </item>
  </channel>
</rss>

