-
Notifications
You must be signed in to change notification settings - Fork 96
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
need larger value of 'ncol' as pivoting occurred #452
Comments
I cannot guess: the error message is not from vegan, but from an external function that vegan calls (and I don't know which function). Please issue |
Looks like the error comes from Note sure that helps us much as that gets called in a few placed that would be hit by the call to |
It indeed comes from I expand a bit: we do not call |
Not meaning to necro this but it only seems to occur when using ´by="margin"` with interactions specified in the formula. For example:
|
No reproducible example. Nothing can be done. |
Apologies I was not trying to seek help just state my experience. I can give data for a reproducible example tomorrow but for what it is worth it seems to occur for any large dataset. |
One easy thing that often helps to call |
Now I know where this happens and how we get there. I replaced > qr.X # bogus function to replace base::qr.X
function(...) stop("hit qr.X")
<environment: namespace:base>
> adonis2(dune ~ ., dune.env, by="margin") # by = "margin" hits bogus qr.X which gives an error
Error in qr.X(object$CCA$QR) : hit qr.X
> traceback()
8: stop("hit qr.X") at #1
7: qr.X(object$CCA$QR)
6: model.matrix.rda(object)
5: model.matrix(object)
4: anova.ccabymargin(object, permutations = permutations, model = model,
parallel = parallel, scope = scope)
3: anova.cca(sol, permutations = perm, by = by, parallel = parallel)
2: anova(sol, permutations = perm, by = by, parallel = parallel)
1: adonis2(dune ~ ., dune.env, by = "margin") Standard disclaimer: Don't do this at home! – you do not want to replace Clearly the calling sequence of vegan functions is The same problem should be hit in We need a test case that produces this error. |
Here a reproducible example: > adonis2(dune ~ Moisture * Use * A1, dune.env, by = "margin")
Error in qr.X(object$CCA$QR) :
need larger value of 'ncol' as pivoting occurred
> m <- rda(dune ~ Moisture * Use * A1, dune.env)
> anova(m, by="margin") # anova.ccabymargin calls model.matrix
Error in qr.X(object$CCA$QR) :
need larger value of 'ncol' as pivoting occurred
> anova(m, by="axis") # anova.ccabyaxis calls model.matrix
Error in qr.X(object$CCA$QR) :
need larger value of 'ncol' as pivoting occurred Here the core of the problem: > m
Call: rda(formula = dune ~ Moisture * Use * A1, data = dune.env)
Inertia Proportion Rank
Total 84.12368 1.00000
Constrained 78.15147 0.92901 17
Unconstrained 5.97222 0.07099 2
Inertia is variance
Some constraints or conditions were aliased because they were redundant
## -- clip -- ##
> alias(m, names=TRUE)
[1] "Moisture.Q:Use.Q" "Moisture.C:Use.Q" "Moisture.C:A1"
[4] "Moisture.C:Use.L:A1" "Moisture.Q:Use.Q:A1" "Moisture.C:Use.Q:A1" Explanation: when you have higher-order interactions, some of these interaction terms become redundant and explain nothing. In this case, the rank of constrained component was 17 leaving 2 degrees of freedom for the residual component. Six interaction terms were aliased, meaning that the full design matrix had 17 + 6 = 23 columns. The data have 20 rows (observations), and with its default settings There is an argument ( This error will occur in special cases: the number of non-aliased terms must be < n-1 so that there is residual variation left and > adonis2(dune ~ matrix(runif(20*19), 20, 19), dune.env, by = "margin")
No residual component
adonis2(formula = dune ~ matrix(runif(20 * 19), 20, 19), data = dune.env, by = "margin")
Df SumOfSqs R2 F Pr(>F)
Model 19 4.299 1
Residual 0 0.000 0
Total 19 4.299 1 I think it makes no sense to use |
model.matrix fails if the full model matrix has more columns than there are observations, but number of non-aliased parameters was lower than the number observations. This typically happens with models with high-order interactions. This was reported for marginal models in adonis2 (issue #452) but also affects constrained ordination methods (rda, cca, dbrda) in anova with by="margin" or by="axis".
This is fixed in commit a64ed4e. Please check this and report on success. The error occurred with two conditions:
Most commonly this happened in models with high-order interactions including factor variables which typically have several redundant combinations of factor levels. The bug affected Although the bug is now avoided, you usually do not want to have permutations tests |
Hi,
I used
adonis2
with the following codeadonis2(df_pathway_f~., bgc_exp_f, permutations = 999, distance = 'bray', by = "margin")
But I got the error
need larger value of 'ncol' as pivoting occurred
I understand this is due to too large size of
bgc_exp_f
with ~160 columns, could you have any clues on how to fix it. Thanks in advance!The text was updated successfully, but these errors were encountered: