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

decorana yields different outputs for different versions of vegan #303

Closed
jannes-m opened this issue Jan 16, 2019 · 2 comments
Closed

decorana yields different outputs for different versions of vegan #303

jannes-m opened this issue Jan 16, 2019 · 2 comments
Labels
Milestone

Comments

@jannes-m
Copy link

Dear Jari,
first of all, thanks for your fantastic package which I have probably been using for more than ten years.
I have stumbled across some inconsistency regarding the output of decorona. Specifically, decorana returns different results since vegan package version 2.5-1 compared to package version 2.4-6.

So, first of all, let's download and install vegan 2.4-6 and subject the varechem dataset to a DCA. I save the decorana output in a directory created by rappdirs.

devtools::install_version("vegan", version = "2.4-6",
                          repos = "http://cran.us.r-project.org")
#> Downloading package from url: http://cran.us.r-project.org/src/contrib/Archive/vegan/vegan_2.4-6.tar.gz
#> Installing package into '/home/jannes/R/x86_64-pc-linux-gnu-library/3.5'
#> (as 'lib' is unspecified)
library("vegan")
#> Loading required package: permute
#> Loading required package: lattice
#> This is vegan 2.4-6
packageVersion("vegan")
#> [1] '2.4.6'
# attach varespec data
data("varespec")
# compute DCA
dca_1 = decorana(varespec, iweigh = 1)
# save it to a "temporary" file
saveRDS(dca_1, file.path(rappdirs::user_data_dir(), "dca_1.rds"))

Created on 2019-01-16 by the reprex package (v0.2.1)

Secondly, I have terminated R and RStudio and opened RStudio again (pls note that a simple R session restart is not sufficient, instead one has to properly close R and RStudio). This time, I will install vegan from CRAN, run again a DCA on the varespec dataset and compare the results between vegan package versions 2.4-6 and 2.5-3.

devtools::install_cran("vegan")
#> Installing 1 packages: vegan
#> Installing package into '/home/jannes/R/x86_64-pc-linux-gnu-library/3.5'
#> (as 'lib' is unspecified)
library("vegan")  # 2.5.3
#> Loading required package: permute
#> Loading required package: lattice
#> This is vegan 2.5-3
packageVersion("vegan")
#> [1] '2.5.3'

# attach varespec and run the same DCA again
data("varespec")
dca_2 = decorana(varespec, iweigh = 1)

# attach first dca result
dca_1 = readRDS(file.path(rappdirs::user_data_dir(), "dca_1.rds"))

# compare DCA results 
all.equal(scores(dca_1), scores(dca_2))
#> [1] "Mean relative difference: 1.786744"
par(mfrow = c(1, 2))
plot(dca_1)
plot(dca_2)

Created on 2019-01-16 by the reprex package (v0.2.1)

It turns out that the results differ substantially. So the question is which result is correct? Looking at the NEWS, is it possible that a bug was introduced when increasing the performance of decorana in package version 2.5-1?

@jarioksa jarioksa added the bug label Jan 16, 2019
jarioksa pushed a commit that referenced this issue Jan 16, 2019
This was reported as an issue #303 in https://github.com/vegandevs/vegan.
The bug was introduced in streamlining of the code for vegan 2.5-0,
and concerns downweighted analysis (iweigh = 1).
@jarioksa
Copy link
Contributor

Yes, this is a bug, and it concerns downweighted analysis (argument iweigh = 1): the row and column sums must be evaluated after downweighting. The bug is fixed in commit 0de6bc4 and the fix will be ported to vegan_2.5-4.

jarioksa pushed a commit that referenced this issue Jan 16, 2019
This was reported as an issue #303 in https://github.com/vegandevs/vegan.
The bug was introduced in streamlining of the code for vegan 2.5-0,
and concerns downweighted analysis (iweigh = 1).

(cherry picked from commit 0de6bc4)
@jannes-m
Copy link
Author

Thanks for the quick answer and the quick fix!!

@jarioksa jarioksa added this to the 2.5-4 milestone Jan 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants