Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In constrained ordination models such as dbrda, variables that are collinear and do not explain any variance are excluded from the model. For example, if a user models patient ID as a random effect along with other explanatory variables (sample type, diagnosis), collinear variables such as diagnosis may be excluded
data ~ sample_type + diagnosis + Condition(patient_id)
When testing for the significance of the variance explained by each variable,
anova.cca(by = "margin")
callspermutest()
for each variable.vegan/R/anova.ccabyterm.R
Line 93 in cf603e1
If a variable is excluded from the model due to collinearity, no constrained variance is available, and
permutest()
returns a result withnum = 0
.vegan/R/permutest.cca.R
Line 13 in cf603e1
The current implementation works if the excluded variable is the only variable in the model. In this case, the method successfully handles the situation. However, if the model contains both variables that explain variance and variables that do not, the function produces an error.
The error is caused because this line below outputs a list instead of
matrix
ornumeric scalar
:vegan/R/anova.ccabyterm.R
Line 104 in cf603e1
Single numeric value is detected by this line that converts it to
matrix
:vegan/R/anova.ccabyterm.R
Line 106 in cf603e1
If the values are not in
matrix
format, this line below causes an error:vegan/R/anova.ccabyterm.R
Line 108 in cf603e1
I fixed the error by ensuring that the values are in
matrix
format (ncol = N variables, nrow = N permutations). If certain variable was excluded from the model, the corresponding column is filled with 0s.The code below reproduces the problem
-Tuomas