使用多项回归时如何更改 statsmodels 中因变量的参考类别?
我正在尝试更改因变量的参考类别(某人投票支持)使用统计模型。我知道,使用C(社交阶级,治疗(参考= 2))使我可以更改一个自变量的参考类别,在此示例中,社交阶层,但这对因变量不起作用。
logitmodel = smf.mnlogit('C(ELECTIONVOTEALL, Treatment(reference=1)) ~ PMMAY + EUvotedremain +votedyes +C(socialclass, Treatment(reference=2))+ leftRight' , df)
dflogit_fit = logitmodel.fit()
我尝试执行针对因变量的自变量有效的操作,但是这会产生一个错误,该错误指出以下内容:
valueError:endog已评估到具有具有形状的多个列的数组(2038,4)。当变量转换为内og是非数字(例如,bool或str)时,就会发生这种情况。
是否有人知道我如何使用statsmodels更改因变量的参考类别?
I am trying to alter the reference category of the dependent variable (what party somebody voted for) while using statsmodels. I know that using C(socialclass, Treatment(reference=2)) allows me to change the reference category of one of the independent variables, social class in this example but this does not work for the dependent variable.
logitmodel = smf.mnlogit('C(ELECTIONVOTEALL, Treatment(reference=1)) ~ PMMAY + EUvotedremain +votedyes +C(socialclass, Treatment(reference=2))+ leftRight' , df)
dflogit_fit = logitmodel.fit()
I tried to do what had worked for the independent variable to the dependent variable however this produces an error which states the following:
ValueError: endog has evaluated to an array with multiple columns that has shape (2038, 4). This occurs when the variable converted to endog is non-numeric (e.g., bool or str).
Does anybody know how I can change the reference category of the dependent variable using statsmodels?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论