系统在一个热编码变量之后,系统在计算上是奇异的
我正在在R中构建Mlogit模型。该模型正常工作,但是当我添加一列编码变量时,它给了我“系统是计算上的单数”,通常是在相关性高时出现的,但我的变量是单热编码的,所以这是一个问题,
这是模型定义:
#Multinomial Logistic Regression
Model1 <- mlogit(choice ~ 0 | Sex + Age.1+ Household.Income +Area+JobA+JobB+JobC+JobD+JobE , data = DFIDX)
summary(Model1)
如果我删除作业列,则可以正常工作,但是添加它们会给我错误:
这是我的数据集的示例(我没有使用所有列):
编辑:
当我删除一列单热变量的一列时,初始模型可以工作。但是,这是不起作用的,并显示另一个错误:
#Mixed logit Model with random parameters
Model2 <- mlogit(choice ~ 0 | Sex + Age.1+ Household.Income +JobA+JobB , data = DFIDX,
rpar=c("Sex:2" = 'n', "Sex:3" = 'n',
"Age.1:2" = 'n', "Age.1:3" = 'n',
"Household.Income:2" = 'n', "Household.Income:3" = 'n' ,
"JobA:2" = 'n', "JobA:3" = 'n',
"JobB:2" = 'n', "JobB:3" = 'n' ) ,
R = 100 , panel = TRUE)
summary(Model2)
注意:删除了JobC,因为该模型有3个类别,并且按建议删除了1个类别。
I'm building an mlogit model in R. The model works fine but when I add one-hot encoded variables it gives me the "system is computationally singular" which usually comes when correlation is high but my variables are one-hot encoded So Idk how that can be an issue
This is the model definition:
#Multinomial Logistic Regression
Model1 <- mlogit(choice ~ 0 | Sex + Age.1+ Household.Income +Area+JobA+JobB+JobC+JobD+JobE , data = DFIDX)
summary(Model1)
If I remove the job columns then it works fine but adding them gives me error:
This is sample of my dataset (I'm not using all the columns):
EDITED:
The initial model works when I remove one column of one-hot-encoded variables. But this one doesn't work and shows another error:
#Mixed logit Model with random parameters
Model2 <- mlogit(choice ~ 0 | Sex + Age.1+ Household.Income +JobA+JobB , data = DFIDX,
rpar=c("Sex:2" = 'n', "Sex:3" = 'n',
"Age.1:2" = 'n', "Age.1:3" = 'n',
"Household.Income:2" = 'n', "Household.Income:3" = 'n' ,
"JobA:2" = 'n', "JobA:3" = 'n',
"JobB:2" = 'n', "JobB:3" = 'n' ) ,
R = 100 , panel = TRUE)
summary(Model2)
Note: JobC was removed as there was 3 categories for this model and 1 was removed as suggested.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论