I have a wide format data, I'm calling mlogit.data
And I tried implementing a mixed logit model using mlogit package, I have one hot encoded the categorical columns (color,size_group ) is that causing the below error?
numerical features in model_data are log1p transformed.
Complete.choice <- mlogit.data(model_data, choice = "y",
varying = 2:79, shape = "wide", sep = "__", id = "customer_id")
formula <- as.formula("y ~ price + weight + length + height + width + color_white +
color_red + color_black + size_group_1 + size_group_3 + size_group_5 +
size_group_4 + size_group_2 | -1")
# rpar
features <- c("price","weight","length","height","width","color_white",
"color_red","color_black" ,"size_group_1",
"size_group_3","size_group_5","size_group_4","size_group_2" )
random_parameter <- rep("n", 1:length(features))
names(random_parameter) <- features
sample.mxl <- mlogit(formula, Complete.choice , rpar = random_parameter,
R = 40, halton = NA, panel = TRUE, seed = 123, print.level = 0)
Error in solve.default(H, g[!fixed]) :
system is computationally singular: reciprocal condition number = 3.23485e-18