modal-inria / MixtComp

Model-based clustering package for mixed data
Other
12 stars 4 forks source link

variable named z_class with the wrong type in basic mode #7

Closed Quentin62 closed 2 years ago

Quentin62 commented 3 years ago

The variable name z_class is used for LatenClass. In basic mode (data.frame, no model given, so MixtComp infers the model according to the data type), when a variable named z_class is given with the wrong type (numeric instead of integer), it is processed as a gaussian variable and the real z_class variable (partition) can not be accessed in the output and it generates bugs in other functions

library(RMixtComp)

X <- data.frame(x = rnorm(100), y = c(rnorm(50), rnorm(50, 2)), z_class = rep(c(1., NA, 2., NA), each = 25))
sapply(X, class)

res <- mixtCompLearn(X, nClass = 2)

res$variable$type$z_class
# [1] "Gaussian" # instead of "LatentClass"
# res$variable$param$z_class has gaussian parameter

plot(res)
# error

Idea:

When inferring type, refuse to use a variable named z_class if it is not an integer and send a warning to the user