I use the missMDA and the factomineR package to create an object for my mca analysis. It works fine except for the names of the modalities. When I create a mca object without imputation, the names of the modalities are a combination of the underlying variable name and the factor level (like they should). But when I use the missMDA package and create the mca object based on the imputation, the modality names in the resulting mca object are named only after the factor levels.
An example:
library(tidyverse)
library(FactoMineR)
library(factoextra)
library(missMDA)
I have data about preferences for oranges and apples, containing missings.
x <- data.frame("oranges" = sample(c("like", "dislike", NA), size = rownr, replace = TRUE),
"apples" = sample(c("like", "dislike", NA), size = rownr, replace = TRUE)) %>%
mutate(oranges = as.factor(oranges)) %>%
mutate(apples = as.factor(apples))
Creating the mca object without imputation results in meaningful modality names: mca_no_imp <- MCA(x, graph = FALSE)
rownames(mca_no_imp$var$coord)
[1] "oranges.NA" "oranges_dislike" "oranges_like" "apples.NA" "apples_dislike" "apples_like"
However, creating the mca object with imputation results in these modality names:
tab.disj <- imputeMCA(x, ncp = 1)$tab.disj
mca_w_imp <- MCA(x, tab.disj = tab.disj, graph = FALSE)
rownames(mca_w_imp$var$coord)
[1] "dislike" "like" "dislike" "like"
I already have a workaround for this problem: I create one mca object with imputation and one without and transfer the rownames. It works but it is cumbersome and prone to error. Has anyone an idea how to avoid the problem in the first place?
Thanks in advance!