Horje
Supplementary Qualitative Variable Labels in FactoMinR

The FactoMineR is a powerful R package designed for multivariate data analysis including the Principal Component Analysis (PCA), Correspondence Analysis (CA), and Multiple Correspondence Analysis (MCA). One of the key features of FactoMineR is the ability to handle supplementary variables. This article will focus on how to handle supplementary qualitative variable labels in the FactoMineR.

What are Supplementary Variables?

The Supplementary variables also known as illustrative or passive variables are variables that do not contribute to the construction of the principal components in the analysis but are projected into the analysis space a posteriori. These variables can provide additional insights without influencing the primary results.

Why Use Supplementary Variables?

The Supplementary variables can help in interpreting the results of the analysis by providing additional context. They can also be used to verify the robustness of the analysis by checking how well they fit into the structure defined by the active variables.

FactoMineR Overview

The FactoMineR offers several functions for the multivariate analysis including:

  • PCA(): Principal Component Analysis
  • CA(): Correspondence Analysis
  • MCA(): Multiple Correspondence Analysis

For each of these functions, we can specify supplementary variables that will be included in the analysis without the influencing the primary structure.

Let’s walk through an example of how to include the supplementary qualitative variables in an MCA using the FactoMineR using R Programming Language.

Step 1. Install and Load FactoMineR

First, ensure that FactoMineR is installed and loaded in the R environment.

R
install.packages("FactoMineR")
library(FactoMineR)
library(factoextra)  # For better visualization

Step 2. Prepare Your Data

For this example, we will use a sample dataset that includes both the active and supplementary qualitative variables.

R
# Sample data
data <- data.frame(
  Age = c("Young", "Adult", "Adult", "Senior", "Senior", "Young", "Adult", "Senior"),
  Gender = c("Male", "Female", "Female", "Male", "Female", "Female", "Male", "Male"),
  Occupation = c("Student", "Engineer", "Doctor", "Retired", "Retired", "Student", 
                 "Engineer", "Retired"),
  Supplementary = c("Yes", "No", "No", "Yes", "Yes", "No", "No", "Yes")
)
# Define active and supplementary qualitative variables
active_vars <- data[, 1:3]
supp_vars <- data[, 4]

Step 3. Perform MCA with Supplementary Variables

To include supplementary variables in the MCA use the MCA() function and specify the supplementary variables.

R
mca_result <- MCA(data, 
                  quanti.sup = NULL, 
                  quali.sup = 4, # Column index of the supplementary 
                  graph = FALSE)
mca_result

Output:

**Results of the Multiple Correspondence Analysis (MCA)**
The analysis was performed on 8 individuals, described by 4 variables
*The results are available in the following objects:

   name                description                                          
1  "$eig"              "eigenvalues"                                        
2  "$var"              "results for the variables"                          
3  "$var$coord"        "coord. of the categories"                           
4  "$var$cos2"         "cos2 for the categories"                            
5  "$var$contrib"      "contributions of the categories".........................................................

Step 4. Visualize the Results

The FactoMineR integrates well with the factoextra package in which provides convenient functions for the visualizing multivariate analysis results.

R
fviz_mca_biplot(mca_result, 
                label = "var", 
                habillage = "Supplementary",  # Highlight supplementary variable
                addEllipses = TRUE, 
                ellipse.level = 0.95)

Output:

gh

Supplementary Qualitative Variable Labels in FactoMinR

1. Visualize Individuals

To visualize individuals with the supplementary variable, use:

R
fviz_mca_ind(mca_result, 
             habillage = 4,  # Index of the supplementary qualitative variable
             addEllipses = TRUE, 
             ellipse.level = 0.95)

Output:

gh

Supplementary Qualitative Variable Labels in FactoMinR

b. Visualize Variables

To visualize active variables and supplementary qualitative variables:

R
fviz_mca_var(mca_result, 
             label = "all", 
             repel = TRUE)

Output:

gh

Supplementary Qualitative Variable Labels in FactoMinR

The biplot provides a simultaneous representation of both the individuals and variables in the MCA space. The Points closer together represent individuals or categories with the similar profiles. The Supplementary variables do not influence the construction of the MCA dimensions but are projected into the space defined by the active variables. They help to see how well the supplementary categories fit within existing structure.

Conclusion

Using supplementary qualitative variable labels in the FactoMineR enhances the interpretability of the multivariate analysis by providing the additional context without the altering the primary structure. By following the steps outlined in this article, we can effectively incorporate and visualize supplementary qualitative variables in the analyses.

Supplementary Qualitative Variable Labels in FactoMinR-FAQs

1. What are the benefits of using supplementary variables?

The Supplementary variables help to interpret the results by providing the additional context and verifying the robustness of the analysis without the influencing the primary structure.

2. Can I use both qualitative and quantitative supplementary variables in FactoMineR?

Yes, The FactoMineR allows for both qualitative and quantitative supplementary variables in the analyses like PCA, CA and MCA.

3. How do I interpret the positions of supplementary variables in the biplot?

The positions of the supplementary variables in biplot indicate their relationship with the active variables and individuals. They show how well these variables fit within the structure defined by the active variables.

4. What other analyses in FactoMineR support supplementary variables?

Other analyses in the FactoMineR that support supplementary variables include the Principal Component Analysis (PCA) and Correspondence Analysis (CA).




Reffered: https://www.geeksforgeeks.org


R Language

Related
How to use a variable in dplyr::filter? How to use a variable in dplyr::filter?
How to Install plotly in Anaconda for R How to Install plotly in Anaconda for R
Saving grid.arrange() Plot to File in R Saving grid.arrange() Plot to File in R
Create a Matrix of Scatterplots (pairs() Equivalent) in ggplot2 Create a Matrix of Scatterplots (pairs() Equivalent) in ggplot2
How to create a reusable plot_ly function in R How to create a reusable plot_ly function in R

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
19