[R] trouble with boot ()

Rogério Rosa da Silva rogeriorosas at gmail.com
Wed May 31 21:27:17 CEST 2006


    Dear members,


    I am trying to use boot () to compute the distributions of a statistic
    of a data set. The statistic is defined in the following code:

        eds<-function(x) {
            r<-cor(x)
            paren<-1-abs(r)/2
            denom<-sum(sum(paren)+0.5)
            desvio<-sd(x)
            media<-mean(x)
            a<-desvio/media
            nom<-sum(a*(sum(paren)+0.5))
            eds_abs<-nom/denom
            print(eds_abs)
            }

    I need to calculate the nonparametric bootstrap confidence intervals for
    "eds_abs", but I am confuse about how I should call the second argument
    for statistic function (). What I don't understand is where the index
    should be set.

    I think I need to reproduce in boot () the following
    loop:

        eds_null <- numeric(1000)
        for (i in 1:1000) eds_null[i] <- eds (sample(x,replace=T)),

    where "x" is a data matrix (n-by-m) with n rows corresponding to
    individual samples, and m-columns corresponding to the different
    attributes. For example:
                                       
x<-data.frame(var1=c(23,657,67,89,23,657,67,89),var2=c(23,45,67,12,23,657,67,89),
var3=c(25,2009,89,223,23,45,67,12),
var4=c(1299,456,789,2, 23,45,67,12))
> eds(x)
> [1] 6.738244

    Thanks for your time,

    Rogério



More information about the R-help mailing list