Hi,

I'd like some advice on bootstrapping in R.

I have a species x with 20 individuals and a factor containing 0 and 1's
(in this case 5 zeros and 15 ones). I want to compare the frequency of
the occurrence of 1 with a probability value. This code seems to work to
do this in R.

attach(test)
p <- c(0.5272, (1-0.5272))
sp1_1 <- length(subset(x, x==1))
sp1_0 <- length(subset(x, x==0))
obs1_1 <- c(sp1_1, sp1_0)
chisq.test(obs1_1, p=p)

However, I'd like to bootstrap these 20 individuals to produce a whole
population of samples and I'd like to do a chi-square test for each of
the bootstrap sample to create a distribution of the chi-square
statistic.

I have bootstrapped the 0's and 1's of x 20 times using the following
code:

resamples <- lapply(1:20, function(i) sample(x, replace=T))

What I can't get to work is how to calculate the observed values for 1's
and 0's in each of the bootstrap samples, which I need to do a
chi-square test for each sample. The methd I used above doesn't seem to
work the results for resamples. Does anyone have an idea on how to get
this to work? Or is there another easier way to do this? I hope it is
clear what I am trying to do!

I have tried looking on the internet and in the R archives, but I can't
find what I am looking for.

Thanks very much in advance for your help!
Geertje

~~~~
Geertje van der Heijden
PhD student
Tropical Ecology
School of Geography
University of Leeds
Leeds LS2 9JT

Tel: (+44)(0)113 3433345 
Email: g.m.f.vanderheijden04@leeds.ac.uk



	[[alternative HTML version deleted]]

