JohnsonHsieh / SpadeR

Species Prediction and Diversity Estimation with R
1 stars 0 forks source link

Error in SpadeR - SpecinciiChao2 function #3

Open oldi opened 8 years ago

oldi commented 8 years ago

Hi there,

I tracked down an error that occurred with a specific incidence vector I am currently analysing. Its onne out of 35, all others are doing fine!. The error occurs in ChaoSpecies and Diversity for datatype = "incidicence", which both make use of the SpecinciiChao2.r function. I opened up the function in this repository and found that the error happens in Line 121:

L121 var_iChao2 <- sum(mapply(function(i, j)diff(i, x)*diff(j, x)*COV.q(i, j), i, j))

which produces a NaN output. Strangely, this only happens for this particular dataset (see below). Any ideas why?

122 119 79 70 61 60 39 32 30 29 28 28 26 21 20 15 11 8 8 6 3 2 1 1 1 1 1 1 1

Interestingly, if I choose datatype="abundance" it works well, too.