Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simpson index #194

Open
1 of 5 tasks
grunwald opened this issue Sep 2, 2018 · 3 comments
Open
1 of 5 tasks

Simpson index #194

grunwald opened this issue Sep 2, 2018 · 3 comments

Comments

@grunwald
Copy link
Member

grunwald commented Sep 2, 2018

Please place an "x" in all the boxes that apply

  • I have the most recent version of poppr and R
  • I have found a bug
  • I want to request a new feature

The Simpson index lambda as calculated is actually 1 - lambda (not lambda). This should be clarified in the vignette and user manuals. I suggest keeping 1 - lambda because when lambda = 0 this represents infinite diversity and lambda = 1 is no diversity. With 1 – lambda, 0 represents no diversity and 1 represents maximal diversity, which is more intuitive.

@grunwald
Copy link
Member Author

grunwald commented Sep 4, 2018

Michael suggested a revision in wording as follows:

“I suggest keeping 1 - lambda because when lambda = 0 represents infinite diversity and lambda = 1 is no diversity. With 1 – lambda, 0 represents no diversity and 1 represents maximal diversity, which is more intuitive.”

@zkamvar
Copy link
Member

zkamvar commented Sep 5, 2018

So, to document this a bit further:

The problem is that poppr() and diversity_stats() return a value called "lambda" as part of their output.

What poppr is returning is actually 1-lambda, which happens to be Simpson's Index of Diversity (as opposed to lambda, which is Simpson's Index). As a bit of background, poppr uses vegan::diversity() for Simpson's diversity index (0). I got confused, assuming that Simpson's Index == Simpson's Diversity Index (which, incidentally, is a pretty common mistake (1)), ignoring the fact that Inverse Simpson's didn't make sense if using Simpson's diversity index as lambda.

the question becomes how to address it. I can do one of two things:

  • update the calculation itself and return the true lambda, but then it's no longer a diversity index
  • update the name of the returned index to 1-lambda, but that will break user workflows.

As both Michael and Nik pointed out, changing the calculation to match the variable name doesn't make sense because lambda itself doesn't make sense in terms of diversity, so we will update the name of the output and revising the documentation.

Funny enough, the function locus_table() correctly returns Simpson's diversity index labeled as 1-D.

Now, I just need to think about how to name it. Anything I name it will break backwards compatibility, but naming it something like 1-lambda is awkward since it makes things difficult to subset.

@zkamvar
Copy link
Member

zkamvar commented Sep 5, 2018

For reference, here are all the instances of "lambda" in the code:

https://github.com/grunwaldlab/poppr/search?l=R&q=lambda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants