JohnsonHsieh / iNEXT

R package for interpolation and extrapolation
https://JohnsonHsieh.github.com/iNEXT
57 stars 26 forks source link

Estimation is not robust - Warning messages: 1: In BootstrapFun.abun #31

Closed equihuam closed 6 years ago

equihuam commented 6 years ago

I am running on Windows 8.1 (x64), Rstudio 1.0.143 and iNEXT 2.0.14

My data set is:

siteA <- c(1, 124, 184, 9, 8, 5, 12, 0, 0, 3, 1, 24, 0, 1, 181)
siteB <- c(0, 7, 0, 19, 7, 0, 0, 1, 0, 0, 0, 0, 3, 0, 79)
siteC <- c(0, 40, 0, 5, 0, 2, 2, 2, 3, 2, 0, 0, 0, 3, 49)
siteD <- c(0, 47, 0, 24, 7, 2, 2, 3, 3, 2, 0, 0, 3, 3, 128)

data <- data.frame(siteA, siteB, siteC, siteD)

I used this code lines:

iNEXT(data, q = 0, datatype = "abundance", size = NULL, knots = 40, se = TRUE, 
           conf = 0.95, endpoint = NULL, nboot = 50)

The result issued missleading warnings stating that only one species was found (when richness is correctly reported in the summary):

Warning messages: 1: In BootstrapFun.abun(x = x, FunName, datatype, B) : This site has only one species. Estimation is not robust. 2: In BootstrapFun.abun(x = x, FunName, datatype, B) : This site has only one species. Estimation is not robust. 3: In BootstrapFun.abun(x = x, FunName, datatype, B) : This site has only one species. Estimation is not robust. 4: In BootstrapFun.abun(x = x, FunName, datatype, B) : This site has only one species. Estimation is not robust. 5: In BootstrapFun.abun(x = x, FunName, datatype, B) : This site has only one species. Estimation is not robust. 6: In BootstrapFun.abun(x = x, FunName, datatype, B) : This site has only one species. Estimation is not robust.

But all the estimates seemed to be OK:

 $AsyEst: asymptotic diversity estimates along with related statistics.
     Site         Diversity Observed Estimator  s.e.    LCL    UCL
 1  siteA  Species richness   12.000    14.995 4.509 12.355 37.265
 2  siteA Shannon diversity    4.571     4.634 0.202  4.571  5.030
 3  siteA Simpson diversity    3.689     3.707 0.114  3.689  3.931
 4  siteB  Species richness    6.000     6.000 0.528  6.000  7.565
 5  siteB Shannon diversity    2.808     2.872 0.298  2.808  3.456
 6  siteB Simpson diversity    2.005     2.023 0.214  2.005  2.443
 7  siteC  Species richness    9.000     9.000 0.742  9.000 11.265
 8  siteC Shannon diversity    3.909     4.065 0.372  3.909  4.794
 9  siteC Simpson diversity    2.873     2.924 0.260  2.873  3.433
 10 siteD  Species richness   11.000    11.000 0.730 11.000 13.155
 11 siteD Shannon diversity    3.867     3.959 0.282  3.867  4.512
 12 siteD Simpson diversity    2.604     2.623 0.206  2.604  3.028

If I change the first line of the data.frame replacing "zeroes" with "ones", like so:

data [1, 2:4] <- 1

No warnings are produced.

andbeck commented 6 years ago

Hi - I am facing a similar situation: the warning message from iNEXT seems incorrect. I find that iNEXT is not happy with a list of species abundances that does not include at least one species with an abundance of 1. If there is one species with a 1 abundance, and one with a 0, it seems OK, oddly.

If we use the spider data built in....

library(iNEXT)

data(spider)

# spider data, focus on Girdled
data(spider)

# create 7 abundance vectors with various amounts of 1's and 0.
spiderG1 <- spider$Girdled # OK
spiderG2 <- spider$Girdled[spider$Girdled>1]  # Incorrect Warning
spiderG3 <- c(spider$Girdled[spider$Girdled>1],1,1)  # OK
spiderG4 <- c(spider$Girdled[spider$Girdled>1],1) # OK
spiderG5 <- c(spider$Girdled[spider$Girdled>1],1,0) # Oddly OK
spiderG6 <- c(spider$Girdled[spider$Girdled>1],0) # Incorrect Warning
spiderG7 <- c(spider$Girdled[spider$Girdled>1],0,0) # Incorrect Warning

iNEXT(spiderG1)
iNEXT(spiderG2)
iNEXT(spiderG3)
iNEXT(spiderG4)
iNEXT(spiderG5)
iNEXT(spiderG6)
iNEXT(spiderG7)

I understand that we should probably remove 0's (?), but perhaps this is also something that can happen in iNEXT? The raw data for species rich but low abundance/site situations will be a very ragged list when 0's are removed in advance (which is fine, if you want the user to manage this).

kobusbosman commented 6 years ago

In my experience and in congruence with andbeck the error is only absent when there are both 2's and 1's in the vector. Only 1 or only 2 or neither messes things up. Much appreciated if this can be fixed!!

JohnsonHsieh commented 6 years ago

This issue had been fixed in iNEXT version 2.0.16 :)

ghost commented 4 years ago

Hello! I have been struggling with a similar issue now for a while, even though I am using iNext 2.0.20 (on RStudio 1.3.903, R 3.6.1, mac Sierra). I have a data set (data frame with rows being species and columns being sites) with some sites having very few species, and I can only make iNext run without error message if I filter these sites away. Specifically, my sites mostly have thousands of species , but there are a few that have only 0-10. If I let these be in the data, I get an error message:

df_inext <- prepare_inext(df, correct_singletons = F) inextobject<- iNEXT(df_inext)

"The Bootstrap community has only one species. Estimation is not robust.no non-missing arguments to max; returning -Inf"

If I try plotting the result with ggiNext, it gives another error:

ggiNEXT(inextobject, type = 1) + theme(legend.position="none")

Error in rbind(deparse.level, ...) : numbers of columns of arguments do not match

If I filter these few low-sample-size samples out, then the errors disappear. However, I am not sure if the resulting completeness curves and asymptotic diversity estimates are reliable, if they are based on a data that has all low-diversity samples filtered out? I'm trying to use iNext to estimate at what sample size the completeness curve plateaus and how sample size per site affects diversity estimates and correct them accordingly.