0

I am currently trying to run a dbRDA using the vegan package. I used three explanatory matrices to explain one response distance matrix:

full.rda <- dbrda(bsim ~ genmat + envmat + spamat)

The first one is a distance matrix while the last three are matrices (not data frames). I checked the dimnames attributes of each, no missing values either, overall everything seems ok...

dim(bsim)

[1] 380 380

dim(envmat)

[1] 380 6

dim(spamat)

[1] 380 3

dim(genmat)

[1] 380 2

all(attr(genmat, 'dimnames')[[1]] == attr(bsim, 'dimnames')[[1]])

[1] TRUE

all(attr(spamat, 'dimnames')[[1]] == attr(bsim, 'dimnames')[[1]])

[1] TRUE

all(attr(envmat, 'dimnames')[[1]] == attr(bsim, 'dimnames')[[1]])

[1] TRUE

but for some reason here the error message I get :

full.rda <- dbrda(bsim ~ genmat + envmat + spamat)

Error in dimnames(u) <- list(dnam[[1]], c(axnam, negnam)) : length of 'dimnames' [2] not equal to array extent

traceback()

3: ordConstrain(Y, X, Z)

2: ordConstrained(X, d$Y, d$Z, method = "dbrda")

1: dbrda(bsim ~ genmat + envmat + spamat)

I've seen people got this error when they were trying to do a corrplot and use a data frame instead of a matrix but that is not the issue here..

Is there anyone who might have suggestions or ideas to overcome this issue ?

I am using the version 3.5.1 of R and the version 2.5-2 of the vegan package.

Thank you a lot!

Lucie Kcz
  • 1
  • 1
  • I cannot reproduce this. Can you provide a reproducible example? What does `bsim` look like? Is that a symmetric square matrix of dissimilarities? – Jari Oksanen Nov 26 '18 at 18:12
  • `bsim` is a distance matrix but the upper panel and the diagonal are left blank. – Lucie Kcz Nov 27 '18 at 17:48
  • I tried to provide a reproductive example but the matrix is too big, I don't know what to do about it since when I used a certain smaller subset, I don't have an error message anymore. I thought the error might be related to the size of the dataset but with a different subset of the same size, the error message appeared again. I then thought there were some issues in one (or more) specific position(s) within this subset that leads to an error message. But if I split this subset in two, each sub-subset works well. I know it is confusing but I have no idea from what the error might come from... – Lucie Kcz Nov 27 '18 at 20:06
  • I ran the exact same code but using a raw matrix instead of the distance matrix and it worked (I didn't really want to do that though). I still don't understand from what the error was coming from although at least I got the results of the analysis. – Lucie Kcz Nov 28 '18 at 17:33
  • 1
    You wrote "bsim is a distance matrix but the upper panel and the diagonal are left blank." This will **not** be regarded as a distance (dissimilarity) matrix in **R**, but it is regarded as an ordinary rectangular data and will be used to calculate distances of your distances (which makes no sense). You *should* use **R** `"dist"` structures which you can make using function `as.dist()`. `vegan::dbrda()` will also recognize *symmetric* square matrices as dissimilarities, but your matrix was non-symmetric (lower triangle non-zero, upper triangle zero or NA). – Jari Oksanen Nov 30 '18 at 07:50

0 Answers0