I have been trying to run mlogit model on R and its giving me an error. I am new to R and can't find a solution for it. The code runs fine when I remove the Q23* columns from it.
library(mlogit)
library(reshape2)
library(dfidx)
#Data Reading and Cleaning
Data <- read.csv('test.csv')
#Data <- Data[,c(-2,-17:-24)]
Data <- Data[,c(-2)]
#Data
Data <- na.omit(Data)
#Manipulation to prepare Data
Data$id <- 1:nrow(Data)
DataWide = melt(Data, id.vars = c('Sex','AgeA','AgeB','AgeC','AgeD','HouseholdIncomeA','HouseholdIncomeB','HouseholdIncomeC','HouseholdIncomeD','HouseholdIncomeE','JobA','JobB','JobC','Q23S1','Q23S2','Q23S3','Q23S4','Q23S5','Q23S6','Q23S7','Q23S8','Q23S9','Q23S10','id'))
names(DataWide)[names(DataWide) == 'value'] <- 'choice'
DataWide <- DataWide[order(DataWide$id), ]
rownames(DataWide) <- NULL
DataWide$choiceid <- 1:nrow(DataWide)
DataWide <- DataWide[,-25]
#Coercion of Data to dfidx object for panel data
DFIDX <- dfidx(DataWide, choice = "choice", shape = "wide",
idx = list(c("choiceid", "id")), idnames = c("chid", "alt"))
head(DFIDX, 10)
dataset <- mlogit.data(DataWide, choice = "choice", shape="wide")
#Multinomial Logistic Regression
Model1 <- mlogit(choice ~ 0 | Sex + AgeA+AgeB+AgeC+ HouseholdIncomeA+HouseholdIncomeB+HouseholdIncomeC+HouseholdIncomeD +JobA+JobB+Q23S1+Q23S2+Q23S3+Q23S4+Q23S5+Q23S6+Q23S7+Q23S8+Q23S9+Q23S10 , data = DFIDX)
summary(Model1)
Error:
Error in solve.default(H, g[!fixed]): Lapack routine dgesv: system is exactly singular: U[57,57] = 0
Sex,Age,Job,Area,Q23S1,Q23S2,Q23S3,Q23S4,Q23S5,Q23S6,Q23S7,Q23S8,Q23S9,Q23S10,JobA,JobB,JobC,AgeA,AgeB,AgeC,AgeD,HouseholdIncomeA,HouseholdIncomeB,HouseholdIncomeC,HouseholdIncomeD,HouseholdIncomeE 1,69,2,3,3,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,1,0,0,0,0,1 1,48,1,3,3,1,1,1,3,3,1,3,3,2,1,0,0,0,0,1,0,0,0,0,1,0 1,54,1,3,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,0,1,0,0 1,44,1,3,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,1,0,0,0,1 1,60,2,4,3,1,1,1,2,2,1,3,3,3,0,1,0,0,0,0,1,1,0,0,0,0 1,53,1,3,3,1,1,1,3,3,1,3,3,1,1,0,0,0,0,1,0,1,0,0,0,0 2,57,3,4,3,1,1,1,3,3,3,3,3,3,0,0,1,0,0,0,1,0,0,1,0,0 1,66,1,3,3,1,1,1,3,3,3,3,2,1,1,0,0,0,0,0,1,0,0,0,0,1 2,58,3,3,3,1,1,1,2,2,1,2,2,1,0,0,1,0,0,0,1,0,0,0,1,0 1,50,1,4,3,1,1,1,3,3,2,3,3,2,1,0,0,0,0,1,0,0,1,0,0,0 1,57,1,4,3,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0,0,0,1,0 2,60,3,4,3,1,1,1,2,2,1,2,1,1,0,0,1,0,0,0,1,0,0,1,0,0