Correspondence Analysis in R

Описание к видео Correspondence Analysis in R

Correspondence analysis (CA) is an extension of principal component analysis (principal-component-analysis) suited to explore relationships among qualitative variables (or categorical data). Like principal component analysis, it provides a solution for summarizing and visualizing data set in two-dimension plots.
#the codes
Correspondence Analysis in R
library("FactoMineR")
library("factoextra")
library("gplots")
#Data format
head(housetasks)
#Chi-square test to evaluate row and column
chisq =chisq.test(housetasks)
chisq
#compute correspondence analysis
res.ca=CA(housetasks, graph = FALSE)
to get eigenvalue
EV=get_eigenvalue(res.ca)
EV
to look scree plot
fviz_screeplot(res.ca, addlabels = TRUE, ylim = c(0, 50))
Row variables
row= get_ca_row(res.ca)
Coordinates
head(row$coord)
Cos2: quality on the factore map
head(row$cos2)
Contributions to the principal components
head(row$contrib)
##Biplot
fviz_ca_row(res.ca, repel = TRUE)# to look only Row
fviz_ca_biplot(res.ca, repel = TRUE)
#draws a standard asymetric biplot:
fviz_ca_biplot(res.ca,
map ="rowprincipal", arrow = c(TRUE, TRUE),
repel = TRUE)
###########################################################
#method-2 -with function ca
library(ca)
ca1 = ca(housetasks)
sqrt of eigenvalues
ca1$sv
row coordinates
head(ca1$rowcoord)
column coordinates
head(ca1$colcoord)
plot
plot(ca1)
#####################################################
metod -3
CA with function dudi.coa
library(ade4)
apply ca
ca3 = dudi.coa(housetasks, nf = 5, scannf = FALSE)
sqrt of eigenvalues
ca3$eig
row coordinates
head(ca3$li)
column coordinates
head(ca3$co)
#################################
mthod -4
PCA with function afc
library(amap)
apply CA
ca4 = afc(housetasks)
eigenvalues
ca4$eig
row coordinates
head(ca4$scores)
column coordinates
head(ca4$loadings)
plot
plot(ca4)
#####################################
method -5
CA with function corresp
library(MASS)
apply CA
ca5 = corresp(housetasks,4)
sqrt of eigenvalues
ca5$cor
row coordinates
head(ca5$rscore)
column coordinates
head(ca5$cscore)
plot(ca5)
##################################

Комментарии

Информация по комментариям в разработке