Home > Mobile >  In R, factoectra ,how to explain the result of CA (Correspondence Analysis)
In R, factoectra ,how to explain the result of CA (Correspondence Analysis)

Time:10-08

In R, using function 'facto_summarize' can get summary. How to understand the variable 'cos2' ?

library(FactoMineR)
library(factoextra)
data("housetasks")
res.ca <- CA(housetasks, graph = FALSE)

facto_summarize(res.ca, "row", axes = 1:2)[,-1]

enter image description here

CodePudding user response:

cos2 is the square cosine, which describes the correlation of a given point with the a given dimension.

The facto_summarize documentation says

If length(axes) > 1, then the columns contrib and cos2 correspond to the total contributions and total cos2 of the axes.`.

Since you've used facto_summarize with two axes, your output is the showing sum of the cos2 values for Dim1 and Dim2.

# both dims
axes12 <- facto_summarize(res.ca, "row", axes = 1:2)[,-1]
# dim 1 only
axes1 <- facto_summarize(res.ca, "row", axes = 1)[,-1]
# dim 2 only
axes2 <-facto_summarize(res.ca, "row", axes = 2)[,-1]

> as.data.frame(cbind(Dim1 = axes1$cos2, 
Dim2 = axes2$cos2, `Dims1 2` = axes12$cos2))

         Dim1       Dim2   Dims1 2
1  0.73998741 0.18455213 0.9245395
2  0.74160285 0.23235928 0.9739621
3  0.77664011 0.15370323 0.9303433
4  0.50494329 0.40023001 0.9051733
5  0.43981243 0.53501508 0.9748275
6  0.11811778 0.64615253 0.7642703
7  0.06365362 0.74765514 0.8113088
8  0.05304464 0.06642648 0.1194711
9  0.43201860 0.33522911 0.7672477
10 0.16067678 0.83666958 0.9973464
11 0.57601197 0.30880208 0.8848140
12 0.70673575 0.22587147 0.9326072
13 0.02979239 0.96235977 0.9921522

> axes12$cos2 == axes1$cos2   axes2$cos2
 [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
  •  Tags:  
  • r
  • Related