-
Notifications
You must be signed in to change notification settings - Fork 95
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
anova.ccabymargin fails for on a dbrda fit with an interaction term and a Condition #463
Comments
Confirmed. This is a shorter example using vegan data: library(vegan)
data(dune, dune.env)
m <- cca(dune ~ A1 * Management + Condition(Moisture), data=dune.env)
anova(m, by = "margin") # wrong answer This concerns all constrained ordination methods with interaction term in constraints when there is a Condition term, and it seems to occur only in |
@gavinsimpson commit ac87d1b seems to fix this bug. I made some search in the vegan codebase and did not spot any other pieces where this bug crops out. |
@gavinsimpson : vegan has been moving pretty slowly recently, and 2.5-* has diverged so much that I want to base the next release (2.6-1) on the current master. There are some issues that need solving, plus a lot of QA & testing, and I'm busy with another package (Hmsc) currently, but I'll try to do my best. I'll write a personal message to you about some issues that need resolution. |
closed with commit 47e9fc3 |
Consider
This produces
which is clearly incorrect given
The problem comes in
anova.ccabymargin
because invegan/R/anova.ccabyterm.R
Lines 89 to 90 in c43c3b1
the
Condition(p1)
term comes before the interaction term in theterminfo
/term.labels
and then in
vegan/R/anova.ccabyterm.R
Lines 91 to 93 in c43c3b1
we're subsetting the X model matrix to drop the interaction term but that, of course, doesn't have 4 columns. This doesn't fail though because of the
ass != i
bit withass
defined asvegan/R/anova.ccabyterm.R
Line 86 in c43c3b1
which in this case is given by
In that
lapply()
we're subsettingX
withwith
X
beingSo we're not dropping the correct column; we're not dropping anything at all here which explains the
0
fordf
andVariance
columns in the output fromanova.ccabymargin
shown above.I'm not sure how to fix this without potentially causing other problems were I to mess with the formula parsing or custom terminfo stuff.
Looking at
cca.formula
I think the same problem will affect it too, but I haven't tested that yet.The text was updated successfully, but these errors were encountered: