0

I used a Constrained Analysis of Principal Coordinates (CAP) to evaluated if my independent variables could explain the ordination of assemblage composition based on species abundances. However, the output only gave me the proportion explained (60.5%) and the F (2.3023) and P (0.003) values for the whole model. But I don't know how to get the deviance explained by each variable and its p-value. I hope someone can help me.

vare.cap <- capscale(ponds ~ PD + PS + COV100 + COV500,
                      dist="bray")
vare.cap
summary(vare.cap)
anova(vare.cap)
anova(vare.cap, by = "axis")

Results:

Partitioning of squared Bray distance:
              Inertia Proportion
Total           2.714     1.0000
Constrained     1.643     0.6055
Unconstrained   1.071     0.3945

 Df          Variance   F    Pr(>F)   
Model     4   1.6435 2.3023  0.003 **
Residual  6   1.0708
Gavin Simpson
  • 47,626
Mauricio
  • 111

1 Answers1

2

If the variance explained is OK, then this is given by anova(model, by = "margin"). This tests marginal effects, hence this is a test of the amount of additional variance explained by adding that variable to a model that already contains all the other variables.

library("vegan")
data(varespec, varechem)
vare.cap <- capscale(varespec ~ N + P + K + Condition(Al), data = varechem,
                     dist="bray")

anova(vare.cap, by = "margin")

This gives us:

> anova(vare.cap, by = "margin")
Permutation test for capscale under reduced model
Marginal effects of terms
Permutation: free
Number of permutations: 999

Model: capscale(formula = varespec ~ N + P + K + Condition(Al), data = varechem, distance = "bray")
         Df Variance      F Pr(>F)  
N         1  0.27719 1.8616  0.093 .
P         1  0.20764 1.3945  0.191  
K         1  0.22249 1.4943  0.151  
Residual 19  2.82904                
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

If you want the marginal variance explained, then you need to divide those values by with(vare.cap, tot.chi - CA$imaginary.chi) if you have imaginary eigenvalues or vby with(vare.cap, tot.chi) if you don't. For example

> set.seed(1)
> marg <- anova(vare.cap, by = "margin")
> marg
Permutation test for capscale under reduced model
Marginal effects of terms
Permutation: free
Number of permutations: 999

Model: capscale(formula = varespec ~ N + P + K + Condition(Al), data = varechem, distance = "bray")
         Df Variance      F Pr(>F)  
N         1  0.27719 1.8616  0.065 .
P         1  0.20764 1.3945  0.201  
K         1  0.22249 1.4943  0.150  
Residual 19  2.82904                
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> marg$Variance / with(vare.cap, tot.chi - CA$imaginary.chi)
[1] 0.05770665 0.04322702 0.04631963 0.58896598

That last line contains the proportions of variance explained out of the total variance. If you want to ignore (or don't have any) imaginary eigenvalues, then you can just do

> marg$Variance / with(vare.cap, tot.chi)
[1] 0.06099498 0.04569025 0.04895909 0.62252739
Gavin Simpson
  • 47,626
  • I just read a paper (Bender et al. 2013 Global Ecology and Biogeography) where the authors say that the first axis explained 56% and the second one explained 32% of the total variation of the proportion of species within trophic groups. I'm wondering if I'm right (in my case) saying that the independent variables explained 60.5% of the assemblage composition variation or if I should mention the variation explained by the first two axes in this analysis. – Mauricio Jun 17 '15 at 16:19
  • Which do you want? The questions says for variables now you ask for axes. – Gavin Simpson Jun 17 '15 at 16:23
  • I'm looking for the proportion of the species composition variation explained by my independent variables. – Mauricio Jun 17 '15 at 16:26
  • By variables or by axes????!!!!! I've shown you the amount of variance explained by variables (just divide that column of data by the Total or Real Total value in the output from vare.cap. – Gavin Simpson Jun 17 '15 at 16:27
  • Sorry, just by variables. – Mauricio Jun 17 '15 at 16:28
  • I was just asking if I'm right saying that the whole model explained 60.5% of the assemblage composition variation. – Mauricio Jun 17 '15 at 16:37
  • You confused the situation by talking about "by axis" after having also showed that code in your question. Yes, 65% of the variance is explained. – Gavin Simpson Jun 17 '15 at 16:40
  • Ok, now I got it. I apologize for this confusion that I've made. – Mauricio Jun 17 '15 at 16:44