Dear Luis,

I think the bootstrap of levins niche breadth index can be attained via the
following R code.
Please also take a look at the comments provided.

dat <- c(15, 456, 32, 21, 94)

### Define a function to calculate Levin's niche breadth
calc_levins <- function(x){
    pi <- x/sum(x)
    res <- 1/sum(pi^2)
    return(res)
}

## Create an empty vector to store the bootstrap results
b_levins <- c()

for (i in 1:1000){
  ## Create one bootstrap sample (dataset), please note the argument
"replace = TRUE".
  b.dat <- sample(dat, replace = TRUE)

  ## calculate the levins niche breadth index based on resampled data.
  b_levins[i] <- calc_levins(b.dat)
}

## A summary of the bootstrap data
summary(b_levins)

## make a histogram
hist(b_levins)

### 95% Confidence Interval of the bootstrap results
quantile(b_levins, probs = c(0.025, 0.975))

Cheers,

Jinlong

------------------------------------------
*Jinlong ZHANG*, Ph. D
Flora Conservation Department
Kadoorie Farm and Botanic Garden (KFBG), Hong Kong
Homepage: http://phylodiversity.net/jinlongzhang/


On Tue, Jun 4, 2013 at 2:46 PM, Luis Fernando García Hernández <
luysgarcia@gmail.com> wrote:

> Dear All
>
> I have been working on the R fully during very few time and I am really
> novice, so my question may look fool to many of you, but I need to do it.
>
> I have calculated Levin´s index (which is 1/sum(pi)˄2 where pi=available
> source i/sum of all sources) for some data and I have been suggested to
> bottstrap it to improve my results, and here it is where I get lost. I have
> done this
>
>
> sources=c(15, 456, 32, 21, 94)
> sum(sources)
> pi=sources/sum(sources)
> pi2=pi˄2
> B=1/pi2
> B
> Boot=boot(a,sim="parametric", R=100)
>
>
> When I try to make the bootstrap function it says statistics argument is
> missing, I know something is wrong but not really what it is. Any help you
> could give me to know how to solve this would be really great!
>
> I also would like to know in this case how can you get the p-value!
>
> Thanks a lot!
>
>         [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>
>

	[[alternative HTML version deleted]]

