[R] bootstrap

Cody_Hamilton at Edwards.com Cody_Hamilton at Edwards.com
Fri Apr 27 21:58:59 CEST 2007


I believe the problem is with the function you are passing to the statistic
option.  According to the documentation for boot, the statistic option
 A function which when applied to data returns a vector containing the      
 statistic(s) of interest. When sim="parametric", the first argument to     
 statistic must be the data. For each replicate a simulated dataset         
 returned by ran.gen will be passed. In all other cases statistic must take 
 at least two arguments. The first argument passed will always be the       
 original data. The second will be a vector of indices, frequencies or      
 weights which define the bootstrap sample.  [italics added]                
 I haven't verified this yet, but try                                       
 y <- rnorm(100)                                                            
 Quantile <- function(df,i){                                                
    quantile(df[i],  probs=c(0.05,0.95))                                    
 This should give you a 95% CI on the 5th and 95th percentiles,             

             Marc Bernard                                                  
             <bernarduse1 at yaho                                             
             o.fr>                                                      To 
             Sent by:                  r-help at stat.math.ethz.ch            
             r-help-bounces at st                                          cc 
                                       [R] bootstrap                       
             04/27/2007 03:36                                              

Dear All,

  I would like to use a nonparametric bootstrap to calculate the confidence
intervals for the 5% and 95% quantiles using boot.ci. As you know, boot.ci
requires the use of boot to generate bootstrap replicates for my statistic.
However this last function  doesn't work in my case because I am missing
something. Here is an example

  y <- rnorm(100)
  Quantile <- function(df)
quantile(df,  probs=c(0.05,0.95))
  boot.out <- boot(y,Quantile, R=999, sim="ordinary")

  Error in statistic(data, original, ...) : unused argument(s) (c(1, 2, 3,
4, 5, 6, 7, 8

  I think  that it's due to another parameter (stype) that I have not
included but I don't know what this paremeter represents.

  Many thanks for any suggestion.



             [[alternative HTML version deleted]]

R-help at stat.math.ethz.ch mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list