系统在一个热编码变量之后,系统在计算上是奇异的

发布于 2025-02-08 12:27:52 字数 1561 浏览 2 评论 0原文

我正在在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:

enter image description here

This is sample of my dataset (I'm not using all the columns):

enter image description here

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.

Error:
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文