0

Link to data

I'm trying to use adonis (per the persistent advice of an advisor) to see what variation in the data set is due to bee colony (variable OBJECTID) and what is due other variables.

My dataframe is titled bees. Previous, I tried putting the LM into adonis directly with the data frame, but got the " 'x' must be an array of at least two dimensions" error code.

Then, I made the dataframe a matrix using the following code:

mat_bee <- as.matrix(bees)
adonis(Cubital.Index ~ bio_6 + Elevation + Latitude, data = mat_bee)

And I get the following error code:

Error in eval(lhs, data, parent.frame()) :
invalid 'envir' argument of type 'character'

It seems this error code is more broad, and about using a matrix rather than a function-specific error, because when I google the error, the results show this error pops up for many functions. I tried using dist() instead of as.matrix(), but the resulting object eliminated most of the data.

I'm a little confused as to what the next step would be for troubleshooting, and also don't know if I need to include OBJECTID as a predictor if I want to know how much of the variance in the model is explained by belonging to a specific bee colony (basically within vs between group variance within the model).

wissem
  • 58
  • 8
  • " 'x' must be an array of at least two dimensions". Look at the call, what do you have x set to currently? Cubital.Index. How many dimensions does it have? 1: voilà! – AkselA Dec 02 '17 at 18:22
  • Also there is no `bio_6` in your data set. – AkselA Dec 02 '17 at 18:23
  • Shoot, I'll update the data set in a minute. Shouldn't using a distance matrix instead of the original dataframe account for the 1 dimension in cubital index? – wissem Dec 02 '17 at 19:21
  • Why would you want to use a distance matrix? Take a look at the doc and the examples there. lhs: response variables (eg. species data), rhs: explanatory variables (eg. environmental data). – AkselA Dec 02 '17 at 19:28
  • I have a remote advisor who is insistent that I use a distance matrix in adonis to find the proportion of variance each factor explains to see if individuals belonging to a certain colony is impacting my results (within group variance). It seems that the original data set doesn't work with the adonis function because it is univariate or one dimensional, and that using a distance matrix instead should allow me to still use the function. I guess the next step is using vegdist() to try and get the LHS in the correct format, so I'll start there. – wissem Dec 02 '17 at 19:40
  • 1
    Does eg. `adonis(dist(Cubital.Index) ~ OBJECTID * Local, data=bees)` work for you? It does for me, but as for interpreting the output I'm afraid I'm of little help. Maybe try ask at [Cross Validated](https://stats.stackexchange.com)? – AkselA Dec 02 '17 at 19:47
  • @AkselA Hm, I'm getting the error `Error in if (any(lhs < -TOL)) stop("dissimilarities must be non-negative") : missing value where TRUE/FALSE needed` even when I clear my environment and read in the dataset from the link above. Vegdist() doesn't work either. It seems to be an error with dist nested inside of adonis? – wissem Dec 02 '17 at 19:56
  • 1
    Did you remove the NA values? – AkselA Dec 02 '17 at 19:59
  • Nope, can't believe I missed that. THANK YOU for helping me, I felt totally lost in this package! – wissem Dec 02 '17 at 20:01
  • 2
    One obvious user-error is that your `mat_bee` is a matrix: it must be a data frame. Second point is that the LHS should be something that can be turned into distances (or dissimilarities). If `Cubital.Index` is a single variable, it should be a 1-column matrix (`as.matrix(Cubital.Index)`). Still most dissimilarity measures would fail for 1-column data, and the ones you can use (i.e., Euclidean distances) are useless: if you can express your data as Euclidean distances, you should use something else than `adonis`: ordinary `lm` for parametric tests or `rda` for permutational tests are better. – Jari Oksanen Dec 03 '17 at 07:15

0 Answers0