Correspondence Analysis in R

Поділитися
Вставка
  • Опубліковано 9 січ 2023
  • 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)
    ##################################

КОМЕНТАРІ • 3

  • @analauraalves2157
    @analauraalves2157 4 місяці тому

    Prof. Tesfahun, thanks for your videos! I have no R experience and am trying to do a CA. However, the software indicated an error in chisq.test (all entries of 'x' must be nonnegative and finite) and in CA (The following variables are not quantitative: Emojis). I converted the variable Emojis into a factor, but nothing is working. Do you know what I can do? My research aims to understand which emotions are associated with each emoji investigated. I have a frequency table in CSV and Xlsx. Once again, thank you very much!

  • @sakisuf3237
    @sakisuf3237 Рік тому +1

    Sir I want to analyse effect of physicochemical parameters of waterbody on single species of fish. Can u please suggest me what statistical tool should I apply