Skip to content
Prev 26637 / 29559 Next

adonis2 in vegan (distance or abundance matrix)

Der list,

i have came across this interesting feature of vegan's adonis2.

The example in ?adonis2 shows that adonis2takes an abundance matrix, and 
converts it to a distance matrix, as given in "method":

library(vegan)
data(dune)
data(dune.env)

ad1 <- adonis2(dune ~ Management*A1, data = dune.env, method="bray")

Permutation test for adonis under reduced model Terms added sequentially 
(first to last) Permutation: free Number of permutations: 999 
adonis2(formula = dune ~ Management * A1, data = dune.env, method = 
"bray") Df SumOfSqs R2 F Pr(>F) Management 3 1.4686 0.34161 3.2629 0.003 
** A1 1 0.4409 0.10256 2.9387 0.022 * Management:A1 3 0.5892 0.13705 
1.3090 0.228 Residual 12 1.8004 0.41878 Total 19 4.2990 1.00000 --- 
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1

However, it can also handle the direct input of the distance matrix:
dune.dist <- vegdist(dune, method="bray")
ad2 <- adonis2(dune.dist~Management*A1, data = dune.env, method="bray")

Permutation test for adonis under reduced model Terms added sequentially 
(first to last) Permutation: free Number of permutations: 999 
adonis2(formula = dune.dist ~ Management * A1, data = dune.env, method = 
"bray") Df SumOfSqs R2 F Pr(>F) Management 3 1.4686 0.34161 3.2629 0.001 
*** A1 1 0.4409 0.10256 2.9387 0.009 ** Management:A1 3 0.5892 0.13705 
1.3090 0.213 Residual 12 1.8004 0.41878 Total 19 4.2990 1.00000 --- 
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1

Apparently, method="bray" is ignored. Here i thought, because dune.dist 
is a already dist-class object, adonis2 abandons the step of creating a 
distance matrix. However, if i convert the dist-object into a dataframe, 
the output is still the same!

dune.df <- as.data.frame(as.matrix(vegdist(dune, method="bray")))
str(dune.df)

ad3 <- adonis2(dune.df~Management*A1, data = dune.env, method="bray")

Permutation test for adonis under reduced model Terms added sequentially 
(first to last) Permutation: free Number of permutations: 999 
adonis2(formula = dune.df ~ Management * A1, data = dune.env, method = 
"bray") Df SumOfSqs R2 F Pr(>F) Management 3 1.4686 0.34161 3.2629 0.004 
** A1 1 0.4409 0.10256 2.9387 0.016 * Management:A1 3 0.5892 0.13705 
1.3090 0.221 Residual 12 1.8004 0.41878 Total 19 4.2990 1.00000

Even though, method="bray" is specified, dune.df is not converted to a 
dist-object. How is it possible that dune, dune.dist, and dune.df all 
give the same result, despite having different dimensions and classes?
A1 TRUE TRUE TRUE TRUE FALSE Management:A1 TRUE TRUE TRUE TRUE FALSE 
Residual TRUE TRUE TRUE NA NA Total TRUE TRUE TRUE NA NA > ad2 == ad3 Df 
SumOfSqs R2 F Pr(>F) Management TRUE TRUE TRUE TRUE FALSE A1 TRUE TRUE 
TRUE TRUE FALSE Management:A1 TRUE TRUE TRUE TRUE FALSE Residual TRUE 
TRUE TRUE NA NA Total TRUE TRUE TRUE NA NA

Thank you!