# [R] Resample with replacement to produce many rarefaction curves with same number of samples

David L Carlson dcarlson at tamu.edu
Thu Sep 8 17:08:06 CEST 2016

```One way around this would be to use multinomial sampling, but as Stefan indicated, the maximum number of species at any size will, of course be 40 (in your example):

> set.seed(42)
> # Generate one sample
> census <- round(rlnorm(40))
> sum(census) # Sample size
[1] 76
> sum(as.logical(census)) # No of species present
[1] 31
>
> # Create probabilities
> # Add .5 to each 0 value
>
> pcensus <- rmultinom(50, 150, census.adj)
>
> Species <- apply(pcensus, 2, function(x) sum(as.logical(x)))
> quantile(Species)
0%  25%  50%  75% 100%
29   33   34   36   38

So projecting a sample of 76 to 150 gives an estimated median of 34 species.

-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of David L Carlson
Sent: Thursday, September 8, 2016 9:25 AM
To: Stefan Evert; Nick Pardikes
Cc: R-help Mailing List
Subject: Re: [R] Resample with replacement to produce many rarefaction curves with same number of samples

Sampling without replacement will never find more species than there are in your original sample either!

Sampling without replacement treats the sample as the population for the purposes of estimating the outcomes at smaller sample sizes. Sampling with replacement (the same as bootstrapping) treats the sample as one possible outcome of a larger population at that sample size.

There is another consideration. A zero value means different things at different sample sizes. At sample size 10, it means approximately less than 10%, but at sample size 100, it means approximately less than 1%, and so on.

-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Stefan Evert
Sent: Thursday, September 8, 2016 7:46 AM
To: Nick Pardikes
Cc: R-help Mailing List
Subject: Re: [R] Resample with replacement to produce many rarefaction curves with same number of samples

> On 7 Sep 2016, at 00:07, Nick Pardikes <nickpardikes at gmail.com> wrote:
>
> Is there any way to use rarecurve to resample a community (row) with
> replacement the same number of times for all 50 communities? With
> replacement is important because the communities differ greatly in their
> size (number of species).

Are you sure it makes sense to resample with replacement?  This will systematically underestimate the number of species at a given sample size (because of the artificial repetition) and will never find more species than there are in your original sample.

Best,
Stefan
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help