[R] "statistic" term in boot function

David Winsemius dwinsemius at comcast.net
Thu Sep 23 04:47:19 CEST 2010


On Sep 22, 2010, at 12:24 PM, alfredo wrote:

>
> Hi There,
>
> Just a question regarding the function that is specified to boot (I  
> have
> read the help, the manual and online examples.........). The  
> description of
> boot says that the second argument of "statistic" (non parametric  
> bootstrap)
> must be a vector of indices, frequencies or weights which define the
> bootstrap sample. If what I will be bootstrapping is e.g., the mean  
> of a
> vector of length N and I want each observation in the vector to be  
> given
> equal weight, should the second argument be a vector containing "N"  
> 1's?

In the simple case (sample of size N done with replacement) the vector  
will be indices, N in number, and a table operation on that set of  
indices lined up against the original 1:N will show some 0 counts,  
mostly 1's, a few 2's and progressively fewer 3's, 4's,  etc. You do  
not need to construct that vector. That is the task for which boot was  
constructed. The ran.gen function is given that responsibility. Your  
responsibility is to create a function that can accept data and the  
vector of indices.

You can get a "look" at the process by instead tabulating the indices  
from the $t value on one replication.

# The normal call.
 > table(boot(1:100, function(x,i){mean(x[i])}, R=1)$t)
# just one value per replication
49.82
     1

#The non-statistical illustration:
 > table(boot(1:100, function(x,i){I(i)}, R=1)$t)

   1   3   4   5   7   8   9  10  11  12  13  14  15  16  20  22  23   
25  26  28  32  33
   3   1   1   3   2   2   1   1   1   2   1   1   3   1   3   2   1    
3   1   2   1   2
  35  39  40  41  42  45  49  50  51  52  53  54  55  56  57  58  59   
60  62  63  64  65
   1   3   1   1   2   2   2   1   1   1   1   1   2   1   1   2   1    
1   1   2   1   1
  68  70  71  72  73  77  79  80  81  82  83  86  87  89  92  94  95   
96  97  98  99 100
   1   1   2   1   2   1   2   1   2   1   1   2   2   3   1   2   1    
1   1   1   2   1

-- 
David.

>
> Thanks beforehand for your help.
>
> Best,
>
> A
> -- 
> View this message in context: http://r.789695.n4.nabble.com/statistic-term-in-boot-function-tp2550629p2550629.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list