R CCA only displaying 4 vectors

允我心安 提交于 2019-12-24 16:56:00

问题


When I try to make a CCA plot, only 4 out of 25 vectors are displayed.

So, I start by loading my data...

#Load package and Data
library(vegan)
Species <- read.csv("D:/R/Code/TestSpiders.csv", head = TRUE, row.names = 1)
Plants <- read.csv("D:/R/Code/Plants.csv", head = TRUE, row.names = 1)

And then, I make use the following code to make the CCA and plot it.

#Making the CCA
CCA.Plants <- cca(Species, Plants)
plot(CCA.Plants)

Even though my Plants data has much more than 4 columns (it has 25), only 4 vectors are displayed in the resulting CCA graph. These 4 vectors represent the first 4 columns of my Plants dataframe. This does not happen when I use the data used in the CCA example (varespec and varechem). I cannot see any difference in the format of varechem and my Plants data.

This is the result when I input CCA.Plants

Call: cca(X = Species, Y = Plants)

              Inertia Proportion Rank
Total          1.0904     1.0000     
Constrained    0.4789     0.4392    4
Unconstrained  0.6115     0.5608   15
Inertia is mean squared contingency coefficient 
Some constraints were aliased because they were collinear (redundant)

Eigenvalues for constrained axes:
   CCA1    CCA2    CCA3    CCA4 
0.19122 0.16817 0.06850 0.05101 

Eigenvalues for unconstrained axes:
    CA1     CA2     CA3     CA4     CA5     CA6     CA7     CA8     CA9    CA10    CA11    CA12 
0.16984 0.12046 0.06941 0.05250 0.04174 0.03349 0.02291 0.02206 0.02015 0.01970 0.01504 0.00957 
   CA13    CA14    CA15 
0.00802 0.00428 0.00228

Any input is appreciated.


回答1:


The clue is here:

Some constraints were aliased because they were collinear (redundant)

in other words, the other 21 columns of Plants could be created as a linear combination of the four plant species shown in the plot. Those 21 plants contained no extra information and hence are dropped from the analysis.

I also don't think the approach you are using here is a good one. Why should the spiders respond unimodally to linear gradients of plants?

Instead, I would suggest using co-correspondence analysis (Co-CA)for this type of problem. Either the symmetric version if you don't want either set of species to play the predictors or responses, or the predictive version if you really want to predict spiders using plant species composition.

This method (both versions) is implemented in R via my cocorresp package, which is on CRAN, and is based on the original Matlab routines provided as supplementary information to the paper that introduced Co-CA (ter Braak & Schaffers, 2004).

For example:

 ## symmetric CoCA
 data(beetles)
 ## log transform the beetle data
 beetles <- log1p(beetles)
 data(plants)
 ## fit the model
 bp.sym <- coca(beetles ~ ., data = plants, method = "symmetric")
 bp.sym

Giving:

Symmetric Co-Correspondence Analysis

Call: symcoca(y = y, x = x, n.axes = n.axes, R0 = weights, symmetric =
symmetric, nam.dat = nam.dat)

Eigenvalues:
 COCA 1    COCA 2    COCA 3    COCA 4    COCA 5    COCA 6    COCA 7    COCA 8   
 0.2534    0.1289    0.0811    0.0741    0.0585    0.0474    0.0373    0.0320   
 COCA 9   COCA 10   COCA 11   COCA 12   COCA 13   COCA 14   COCA 15   COCA 16   
 0.0308    0.0233    0.0207    0.0184    0.0172    0.0161    0.0144    0.0118   
COCA 17   COCA 18   COCA 19   COCA 20   COCA 21   COCA 22   COCA 23   COCA 24   
 0.0106    0.0100    0.0087    0.0085    0.0066    0.0063    0.0050    0.0044   
COCA 25   COCA 26   COCA 27   COCA 28   COCA 29   
 0.0043    0.0034    0.0022    0.0010    0.0006   

Inertia:
           beetles plants
Total:     3.98833  5.757
Explained: 3.97079  5.740
Residual:  0.01754  0.018

and

layout(matrix(1:2, ncol = 2))
plot(bp.sym, which = "response", main = "Beetles")
plot(bp.sym, which = "predictor", main = "Plants")
layout(1)

Note that in this symmetric analysis, neither set of assemblages plays the response or predictor role, but that is how the plot method chooses which to draw, based on which was on the left or the right hand side of the ~ in the formula.

The predictive Co-CA works similarly.

ter Braak, C.J.F and Schaffers, A.P. (2004) Co-Correspondence Analysis: a new ordination method to relate two community compositions. Ecology 85(3), 834–846



来源:https://stackoverflow.com/questions/36041924/r-cca-only-displaying-4-vectors

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!