The boot() function in the 'boot' package expects to find a function
for the statistic with two arguments: The data object plus a row index object.
You don't indicate enough to see how you will be resampling. It you
sum all elements in your table, resampling would have to be one of:
1. A sample with replacement of rows, or
2. A sample with replacement of columns, or
3. A sample with replacement of elements in the whole table.
Assuming you want sampling with replacement of rows:
sumf<- function (x, i) { sum(x[i,]) }
result<- boot(mytable, sumf, 1000)
boot.ci(result, type='bca')
A simulation:
> mytable<- matrix(rnorm(2000), ncol=20)
> sum(mytable)
[1] -14.92842
> sumf<- function(x,i) sum(x[i,])
> require('boot')
Loading required package: boot
> b1<- boot(mytable, sumf, 1000)
> boot.ci(b1, type='bca')
BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
Based on 1000 bootstrap replicates
CALL :
boot.ci(boot.out = b1, type = "bca")
Intervals :
Level BCa
95% (-101.49, 85.20 )
Calculations and Intervals on Original Scale
At 01:28 PM 2/25/2010, xonix wrote:>Hi all
>Forgive me, I'm a total R newbie, and this seems to be a straightforward
>simple bootstrap problem, but after a whole day of trying to figure out how
>to do it I'm ready to give up. Part of the problem is that every example
and
>every help page seems to be about doing something more far more complex.
>
>
>I'm got a table with 40 columns and 750 rows. I sum all the values
across
>the whole table (and subsets of the columns). I want to bootstrap to get the
>95% confidence intervals for that sum value.
>
>result <- boot(table, <function>, 1000)
>boot.ci (result, bca)
>
>It seems to me that the 'function' is something to sum all the
columns and
>rows of the table (or a subset should I desire). I've tried writing
'sum'
>for the function, but this gives me a huge figure which can't possibly
be
>right.
===============================================================Robert A.
LaBudde, PhD, PAS, Dpl. ACAFS e-mail: ral at lcfltd.com
Least Cost Formulations, Ltd. URL: http://lcfltd.com/
824 Timberlake Drive Tel: 757-467-0954
Virginia Beach, VA 23464-3239 Fax: 757-467-2947
"Vere scire est per causas scire"