JohnsonHsieh / iNEXT

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

ChaoShared cannot calculate when one community is a subset of another #7

Closed PhilippeJeanneret closed 8 years ago

PhilippeJeanneret commented 8 years ago

Dear Johnson, dear Anne, I used SpadeR and tried to calculate the number of shared species in two communities. There are things which seem strange. I already asked Johnson but have got no reply till now. With two communities like this: test <- data.frame(x = 1:20, y = c(0,0,0,0,0,2,4:17)) ChaoShared(test, datatype="abundance", se=TRUE, nboot=200, conf=0.95) I got that error message: Error in rmultinom(B, n2, p2) : NA in probability vector Note that the community "x" has no 0 abundances (all "y" species are occurring in "x").

In contrast, by doing that: test <- data.frame(x = c(1:15,0,0,0,0,0), y = c(0,0,0,0,0,2,4:17)) ChaoShared(test, datatype="abundance", se=TRUE, nboot=200, conf=0.95)

I got normal results. I have tested with several pairs of communities and my conclusion is if one community is a subset of the second one, i.e. one community has no 0 occurences, 'ChaoShared' cannot calculate. Of course, the number of shared species is then the number of species of the smallest community but it would be nice to get estimates and SE. Is that feasible ?

Thank you in advance for your reply. Best wishes, Philippe

PhilippeJeanneret commented 8 years ago

Dear Johnson, Further testing of 'ChaoShared' showed errors difficult to understand: test <- data.frame(v1 = c(1,1,0,0), v2 = c(1,0,1,1)) ChaoShared(test, datatype="abundance", se=TRUE, nboot=200, conf=0.95) gives outputs but this: data.frame(v1 = c(1,1,0,1), v2 = c(1,0,1,0)) results in "Error in rmultinom(B, n2, p2) : NA in probability vector Called from: rmultinom(B, n2, p2)" Quite strange, isn't it? In both cases, both communities have 1 species shared (the first one), one community has 1 exclusive species and the other community has 2 exclusive species. But more remarkably, by reversing v1 and v2, 'ChaoShared' gives an output: test <- data.frame(v1 = c(1,0,1,1), v2 = c(1,1,0,0))

I hope you can help me to understand, respectively resolve the problem. Thanks in advance for your answer. Best regards, Philippe

JohnsonHsieh commented 8 years ago

Please post this question to https://github.com/AnneChao/SpadeR/issues, thanks.

BR Johnson