-
Notifications
You must be signed in to change notification settings - Fork 97
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
Scoping issue in anova.ccabymargin
#100
Comments
There are numerous scoping issues in These scoping issues should be fixed. I know this can be difficult, and there should be regression tests in place to see that nothing is broken when fixing some corners. I fixed one very bad one in https://github.com/jarioksa/vegan/tree/scoping-issue but many other should be fixed. This may require rethinking and simplification of the whole formula interface in constrained ordination. |
Incidentally, the example that @gavinsimpson gave works after jarioksa@b858209 that I made to fix another issue yesterday. > out$Poatriv
Permutation test for rda under reduced model
Marginal effects of terms
Permutation: free
Number of permutations: 999
Model: rda(formula = x ~ Manure + A1, data = env)
Df Variance F Pr(>F)
Manure 4 4.7257 5.7006 0.007 **
A1 1 0.0153 0.0736 0.802
Residual 14 2.9014 Perhaps I need to merge this. |
Here one example that still fails. This is based on X <- matrix(rnorm(30*6), 30, 6)
A <- factor(rep(rep(c("a","b"), each=3),5))
C <- factor(rep(c(1:5), each=6))
mod <- rda(X ~ A + Condition(C))
anova(mod, by="margin")
##Error in model.frame.default(P.formula, data, na.action = na.pass, xlev = zlev) :
## object is not a matrix
mod <- rda(X ~ A + C)
anova(mod, by="term")
##Error in model.frame.default(formula, data, na.action = na.pass, xlev = xlev) :
## invalid type (closure) for variable 'C'
anova(mod, by="margin")
##Error in model.frame.default(formula, data, na.action = na.pass, xlev = xlev) :
## object is not a matrix
mod <- rda(X ~ C)
anova(mod, by="term")
##Error in model.frame.default(formula, data, na.action = na.pass, xlev = xlev) :
## object is not a matrix
anova(mod, by="margin")
##Permutation test for rda under NA model
##Marginal effects of terms
##Permutation: free
##Number of permutations: 999
##
##Model: rda(formula = X ~ C)
## Df Variance F Pr(>F)
##C 4 0.9696 1.2446 0.201
##Residual 25 4.8688 The object that is not a matrix but a closure is |
Related: #16 |
@jarioksa If we were to rethink the formula interface and rewrite that code, would you consider using the Formula package, such that we can have a two-part formula, one for the constraints and one for the conditional (partial) constraints (aka covariables in Canoco, and our current y ~ x1 + x2 | z1 + z2 where I've been thinking about this for a while as one potential alternative way to specify the formula which seems more natural to me, is similar to the way random effects are specified, and we can leverage a widely-used, small, well-tested package for the interface/processing of the formula. Using Formula would add a dependency. Secondly, would it make sense to separate the computational code for say RDA or CCA into simpler, internal, unexported functions, which implement only one aspect of what current The formula interface would then only exist to resolve the data required to fit the model, then call the We could also consider exposing these internal functions if other package writers want to build upon these simpler fitting functions. In my analogue package for example, I wanted a quicker version of |
Quite a few issues here, @gavinsimpson
|
@jarioksa followups:
I guess what I wanted to convey was that if we were going to try to reimplement the scoping, we might consider some larger changes as part of that process. |
Currently the errors come form Factoring |
Agreed, but if we're going to do one (fix or work on the scoping) we could look at the other (improving the UI) as part of those changes. I'm currently digesting what Hadley Wickham has to say about non-standard evaluation and robust ways of implementing this from his Advanced R book. I'll take a look at |
The |
@jarioksa Agreed. That's why I was happy to see that I could implement a Hopefully, by starting from scratch with a clean implementation we might identify the scoping issues which could be backported to the older interface. As I mentioned earlier in this thread; I don't want to break the current UI, just add to it if possible and only if it helps. |
Not sure if we can do much about this now or in the future, but I'm recording it here in case we update something in the future?
The following example illustrates a scoping bug/infelicity that, ideally, we'd be able to handle in vegan
which fails with:
the
traceback()
is:The obvious workaround is
or, retaining
lapply()
:The text was updated successfully, but these errors were encountered: