vegandevs / vegan

R package for community ecologists: popular ordination methods, ecological null models & diversity analysis
https://vegandevs.github.io/vegan/
GNU General Public License v2.0
449 stars 97 forks source link

Issues with formulas in adonis #368

Closed mgoggans closed 4 years ago

mgoggans commented 4 years ago

Hello,

I have an experiment with a repeated measures design. I would like to use PERMANOVA to test the entire model - the vignette says adonis can handle a formula notation, but I am having problems.

Repeated measures ANOVA is denoted as such: dependent.variable ~ between.factor * within.factor + Error(id.of.repeat / within.factor)

When I try to run this, I get "Error: cannot find function "Error" "

This "error" notation in the formula is standard for base R linear models. I don't know why it won't work. Is adonis just not made to function with this type of linear model?

jarioksa commented 4 years ago

Error is not a part of formula documentation. It has been implemented as a special function in aov() (try ?Error which takes you to aov), but will give an error, for instance, in lm where it is not implemented. It is neither implemented in adonis of vegan. We use formula as a way of getting model.matrix for the analysis, and Error() will also fail in model.matrix and model.frame. In this case the error comes from the latter, as you see by issuing traceback() after having the error.

mgoggans commented 4 years ago

@jarioksa Thank you for the thorough answer, very much appreciated!