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

methods for betadisper objects fail when bias.adjust=TRUE #219

Closed
jrcunning opened this issue Dec 1, 2016 · 3 comments
Closed

methods for betadisper objects fail when bias.adjust=TRUE #219

jrcunning opened this issue Dec 1, 2016 · 3 comments
Labels
Milestone

Comments

@jrcunning
Copy link

jrcunning commented Dec 1, 2016

Using the sample code from the permutest.betadisper help text, if the bias.adjust=TRUE is included when building the betadisper object "mod", downstream anova and permutest methods fail, giving this error:

Error in eval(expr, envir, enclos) : object 'Distances' not found

data(varespec)

## Bray-Curtis distances between samples
dis <- vegdist(varespec)

## First 16 sites grazed, remaining 8 sites ungrazed
groups <- factor(c(rep(1,16), rep(2,8)), labels = c("grazed","ungrazed"))

## Calculate multivariate dispersions
mod <- betadisper(dis, groups, bias.adjust=TRUE)
mod

## Perform test
anova(mod)

## Permutation test for F
pmod <- permutest(mod, permutations = 99, pairwise = TRUE)
@jarioksa jarioksa added the bug label Dec 2, 2016
@jarioksa jarioksa added this to the 2.4-2 milestone Dec 2, 2016
jarioksa pushed a commit that referenced this issue Dec 2, 2016
With bias.adjust=TRUE we used table() to get the counts for groups,
and the result had class "table" with special as.data.frame() method.
We used data.frame as the internal structure to pass data to anova
and permutest, and this was distorted with as.data.frame.table().

Fixes issue #219 in github.
@jarioksa
Copy link
Contributor

jarioksa commented Dec 2, 2016

This is a subtle issue: R objects are not always what they look like. We needed counts of observations for groups, and we used table() for that purpose. Although the output of table looks like an ordinary vector, it is a vector of class "table" and has a specific handling in data.frame. When we then built an internal data.frame for anova.betadisper() or permutest.betadisper the result was not like we expected.

I have a fix for this (commit a0e16ea), but we got to see that this fix does not break anything else before merging this.

Thanks for reporting this problem. We are going to have this fix in vegan release 2.4-2 before northern winter solstice.

(cc @adrianstier @bbolker)

jarioksa pushed a commit that referenced this issue Dec 2, 2016
@bbolker
Copy link
Contributor

bbolker commented Dec 2, 2016

OK, I was surprised by this (thought it was an evaluation-environment problem), but I see it's just a renaming issue. Sorry about the trouble.

jarioksa pushed a commit that referenced this issue Dec 8, 2016
@jarioksa
Copy link
Contributor

jarioksa commented Dec 8, 2016

Fixed with commit e70050e

@jarioksa jarioksa closed this as completed Dec 8, 2016
jarioksa pushed a commit that referenced this issue Dec 8, 2016
With bias.adjust=TRUE we used table() to get the counts for groups,
and the result had class "table" with special as.data.frame() method.
We used data.frame as the internal structure to pass data to anova
and permutest, and this was distorted with as.data.frame.table().

Fixes issue #219 in github.

(cherry picked from commit a0e16ea)
jarioksa pushed a commit that referenced this issue Dec 8, 2016
these failed prior to a0e16ea (github issue #219)

(cherry picked from commit fc452ed)
jarioksa pushed a commit that referenced this issue Dec 8, 2016
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

3 participants