Title: | Multiple Correspondence Analysis Based on Interpretive Coordinates |
---|---|
Description: | Various functions and a Shiny app to enrich the results of Multiple Correspondence Analysis with interpretive axes and planes (see Moschidis, Markos, and Thanopoulos, 2022; <doi:10.1108/ACI-07-2022-0191>). |
Authors: | Stratos Moschidis [aut, cre], Angelos Markos [aut] |
Maintainer: | Stratos Moschidis <[email protected]> |
License: | GPL-3 |
Version: | 0.1.2 |
Built: | 2025-02-28 04:48:00 UTC |
Source: | https://github.com/cran/interca |
The function performs multiple correspondence analysis (MCA) on a given data set and a given number of categorical variables. The function returns for each point for each axis the coordinates, the interpretive coordinates, the contributions, and the quality of display.
interca(data = data, numaxes = 10)
interca(data = data, numaxes = 10)
data |
A data frame containing the data to be analyzed. |
numaxes |
The number of categorical variables that will be retained for the calculation of the elements referred to in the function description. |
The function returns a list with the principal MCA coordinates coordinates (coords
), the interpretive MCA coordinates (ecoords
), the values of the CTR (ctr
) and COR (cor
), the labels of the variable categories (lbl
) and the scree plot (plot
).
Moschidis, S., Markos, A., & Thanopoulos, A. C. (2022). "Automatic" interpretation of multiple correspondence analysis (MCA) results for nonexpert users, using R programming. Applied Computing and Informatics, (ahead-of-print).
# Set the seed to ensure reproducibility set.seed(123) # Create three categorical variables X1 <- sample(c("X1_1", "X1_2"), size = 200, replace = TRUE) X2 <- sample(c("X2_1", "X2_2", "X2_3"), size = 200, replace = TRUE) X3 <- sample(c("X3_1", "X3_2", "X3_3", "X3_4"), size = 200, replace = TRUE) # the resulting data frame df <- data.frame(cbind(X1,X2,X3)) # convert to factors df$X1 <- factor(df$X1) df$X2 <- factor(df$X2) df$X3 <- factor(df$X3) res <- interca(df, 5)
# Set the seed to ensure reproducibility set.seed(123) # Create three categorical variables X1 <- sample(c("X1_1", "X1_2"), size = 200, replace = TRUE) X2 <- sample(c("X2_1", "X2_2", "X2_3"), size = 200, replace = TRUE) X3 <- sample(c("X3_1", "X3_2", "X3_3", "X3_4"), size = 200, replace = TRUE) # the resulting data frame df <- data.frame(cbind(X1,X2,X3)) # convert to factors df$X1 <- factor(df$X1) df$X2 <- factor(df$X2) df$X3 <- factor(df$X3) res <- interca(df, 5)
The function runs a Shiny app that allows the user to upload a data file and calculate the MCA output (tables, plots and ready-made reports) through a graphical interface. The data can be loaded in .xslx or csv format and then the number of axes to be retained should be specified. The user can produce an interpretive axis or plane, filter points based on their interpretive coordinates, and download the plots and tables in .pdf (.xlsx) format, as well as a ready report with the interpretation of MPCA results.
intercaShiny()
intercaShiny()
shiny application object
# --- Run the 'shiny' app ## Not run: intercaShiny()
# --- Run the 'shiny' app ## Not run: intercaShiny()
The function takes the result of the interca() function and the number of a factorial axis and returns the corresponding interpretive axis with the most significant points.
plot1d(res, dim = 1)
plot1d(res, dim = 1)
res |
The result of the execution of the interca() function. |
dim |
The number of the interpretive axis to be printed. |
The interca() function must be executed first in order to use the function.
The function returns a ggplot2
scatterplot that corresponds to a single interpretive dimension obtained via interca()
.
interca
# Set the seed to ensure reproducibility set.seed(123) # Create three categorical variables X1 <- sample(c("X1_1", "X1_2"), size = 200, replace = TRUE) X2 <- sample(c("X2_1", "X2_2", "X2_3"), size = 200, replace = TRUE) X3 <- sample(c("X3_1", "X3_2", "X3_3", "X3_4"), size = 200, replace = TRUE) # the resulting data frame df <- data.frame(cbind(X1,X2,X3)) # convert to factors df$X1 <- factor(df$X1) df$X2 <- factor(df$X2) df$X3 <- factor(df$X3) res<-interca(df,5) plot1d(res,1)
# Set the seed to ensure reproducibility set.seed(123) # Create three categorical variables X1 <- sample(c("X1_1", "X1_2"), size = 200, replace = TRUE) X2 <- sample(c("X2_1", "X2_2", "X2_3"), size = 200, replace = TRUE) X3 <- sample(c("X3_1", "X3_2", "X3_3", "X3_4"), size = 200, replace = TRUE) # the resulting data frame df <- data.frame(cbind(X1,X2,X3)) # convert to factors df$X1 <- factor(df$X1) df$X2 <- factor(df$X2) df$X3 <- factor(df$X3) res<-interca(df,5) plot1d(res,1)
The function takes as parameters the result of the interca() function, the interpretive axis that will form the x axis, and the interpretive axis that will form the y axis. The function returns the interpretive plane formed by the above.
plot2d(res, dim1 = 1, dim2 = 2)
plot2d(res, dim1 = 1, dim2 = 2)
res |
The result of the interca() function. |
dim1 |
The number of the interpretive axis that will form the x axis of the interpretive plane. |
dim2 |
The number of the interpretive axis that will form the y axis of the interpretive plane. |
The function returns a ggplot2
scatterplot that corresponds to a 2D interpretive plane obtained via interca()
.
interca
#For the example, we will use the wg93 data frame from the ca package. # Set the seed to ensure reproducibility set.seed(123) # Create three categorical variables X1 <- sample(c("X1_1", "X1_2"), size = 200, replace = TRUE) X2 <- sample(c("X2_1", "X2_2", "X2_3"), size = 200, replace = TRUE) X3 <- sample(c("X3_1", "X3_2", "X3_3", "X3_4"), size = 200, replace = TRUE) # the resulting data frame df <- data.frame(cbind(X1,X2,X3)) # convert to factors df$X1 <- factor(df$X1) df$X2 <- factor(df$X2) df$X3 <- factor(df$X3) res <- interca(df,5) plot2d(res,1,2)
#For the example, we will use the wg93 data frame from the ca package. # Set the seed to ensure reproducibility set.seed(123) # Create three categorical variables X1 <- sample(c("X1_1", "X1_2"), size = 200, replace = TRUE) X2 <- sample(c("X2_1", "X2_2", "X2_3"), size = 200, replace = TRUE) X3 <- sample(c("X3_1", "X3_2", "X3_3", "X3_4"), size = 200, replace = TRUE) # the resulting data frame df <- data.frame(cbind(X1,X2,X3)) # convert to factors df$X1 <- factor(df$X1) df$X2 <- factor(df$X2) df$X3 <- factor(df$X3) res <- interca(df,5) plot2d(res,1,2)