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

Missing (or NA) data for PERMANOVA #319

Closed
Anna1288 opened this issue Jul 11, 2019 · 2 comments
Closed

Missing (or NA) data for PERMANOVA #319

Anna1288 opened this issue Jul 11, 2019 · 2 comments

Comments

@Anna1288
Copy link

I've searched around the threads on here and am not sure I am able to find what I'm looking for. I am hoping to use PERMANOVA to run my analysis, but I do have missing values. I don't seem to be able to run vegdist, adonis, or other related functions with blanks or NA. Is there any way around this?

@jarioksa jarioksa added bug and removed bug labels Jul 12, 2019
@jarioksa
Copy link
Contributor

It seems vegdist silently accepts NA values. It should not, and I'll see how to make it fail with NA unless requested.

The adonis and adonis2 functions do not accept NA values in vegan 2.5-x releases (I tagged this issue first as a bug because of this omission, but this is documented behaviour and hence no bug). The adonis function in the vegan development version 2.6-0 in GitHub handles NA with na.action argument. If you really need to handle NA values, you should use the GitHub version.

Alternatively, you can have listwise deletion of missing values using complete.cases function. Listwise deletion means that the observation is removed if any variable is missing. Here an example:

library(vegan)
data(dune, dune.env)
z <- dune.env
z[12,5] <- NA # one missing value
k <- complete.cases(z) # FALSE for rows with NA
adonis(dune[k,] ~ ., z[k,]) # use complete.cases as row selector

jarioksa pushed a commit that referenced this issue Jul 12, 2019
The documented behaviour was accidentally and silently changed
to always making pairwise deletion of missing values with internal
speed up of C code (commit 3aeeb1d 2016-09-06, released in vegan
2.4-2 2017-01-17). Now we stop with error (like documented). See
also my comment in GitHub issue #319.
jarioksa pushed a commit that referenced this issue Jul 12, 2019
The documented behaviour was accidentally and silently changed
to always making pairwise deletion of missing values with internal
speed up of C code (commit 3aeeb1d 2016-09-06, released in vegan
2.4-2 2017-01-17). Now we stop with error (like documented). See
also my comment in GitHub issue #319.

(cherry picked from commit 2e9969a)
@jarioksa
Copy link
Contributor

jarioksa commented Jul 12, 2019

For the record: commit messages 2e9969a (and cherry-picked f4d5cae) suggest that na.rm was broken in vegan 2.4-2 (2016-09-07). Actually it was broken in 2.5-1 (2018-04-13) where we switched from .C() to .Call() interface: NA are always passed to the compiled code in .Call(), but optionally (like we did) in .C().

@jarioksa jarioksa mentioned this issue Sep 1, 2019
@jarioksa jarioksa closed this as completed Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants