Replies: 4 comments
-
The "w" field will be, I guess, the Population Weights. One value (weight) for each n (in sample), hence w has to be same length as your obs. They will be different if they are population weights, such as (often) much higher weights for known demographics that are undersampled (higher n/r rates, etc). If you just want the arithmetic (sample, not population) mean, just set them all to 1.000. :) |
Beta Was this translation helpful? Give feedback.
-
@MarkReader CCA involves abundance-weighting the data so the error could just as easily be being raised from functions internal to @pauGuas Solve the obvious problem first; that's not how you fit a CCA model. The RHS of the formula should be a standard R formula: If you want to proceed using the defined ord <- cca(prop_dft ~ ., data = ENV[, var]) replacing |
Beta Was this translation helpful? Give feedback.
-
Very likely so. (But, out of curiosity @gavinsimpson what are the "w"? Will be really grateful if you can DM me, if you like.). |
Beta Was this translation helpful? Give feedback.
-
Yes, the error is triggered in an internal function: user should not and cannot supply weights to if (!is.null(RW)) {
envcentre <- apply(X, 2, weighted.mean, w = RW)
X <- scale(X, center = envcentre, scale = FALSE)
X <- sweep(X, 1, sqrt(RW), "*")
} The weights However, I cannot understand how you reach this error. Like @gavinsimpson wrote, the model definition is wrong. Moreover, we do check the dimensions before going to Error in ordConstrained(X, Y, Z, method = "cca") :
dependent data and constraints must have the same number of rows (and I got this when I tried to mimick the original commands – I could not reproduce them as there was nothing reproducible.) The command should only work if The way to proceed is to follow Gav's instruction, and if it still fails, provide a reproducible example (where "reproducible" means something we can run and get the same error). |
Beta Was this translation helpful? Give feedback.
-
Hi, I am trying to run a CCA on the numerical environmental factors that influence microbiome composition (phyloseq object). The environmental factors are summarized in "var". When I run the code below, I get
"Error in weighted.mean.default(newX[, i], ...) : 'x' and 'w' must have the same length".
I don't know what 'w' is in this. Does anyone know what to do with this? Thank you!Beta Was this translation helpful? Give feedback.
All reactions