I am using the mlogit package in R to run a multinomial logistic regression on pooled discrete choice data collected using two different questionnaire formats. I want to test whether the format had a significant effect on choices. When I run the basic model I get a result. But when I run the same model with a dummy variable indicating which format the respondents saw, I get an error: "Error in solve.default(H, g[!fixed]) : Lapack routine dgesv: system is exactly singular"
I was able to replicate the error using Train's Electricity dataset in the mlogit package, setting a dummy based on whether the respondent ID was odd or even:
library(mlogit) data("Electricity", package = "mlogit") Electr <- mlogit.data(Electricity, id = "id", choice = "choice", varying = 3:26, shape = "wide", sep = "") Electr$odd.dummy <- ifelse(Electr$id %% 2 == 0, 0, 1) # As example, set dummy if ID is odd summary(mlogit(choice ~ pf + cl + loc + wk + tod + seas | 0, data=Electr)) # Basic model summary(mlogit(choice ~ pf + cl + loc + wk + tod + seas + odd.dummy | 0, data=Electr)) # Basic + dummy summary(mlogit(choice ~ odd.dummy | 0, data=Electr)) # Only dummy
As with my data, the first model runs, but the second two are singular.
I understand that a result will be singular if there is perfect colinearity between variables, but I don't see how this is the case here. Respondents were randomly assigned to one format or the other, and the underlying experimental design was the same in both formats, so there shouldn't be any colinearity between the dummy and the other variables.
I would be grateful if someone could explain why adding the dummy leads to a singular result, and even more grateful if they could suggest a solution to avoid it.