Python-Logistic回归完全分离

2024-10-03 11:12:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我的问题是用一个logistic模型来测试两个二元因素及其在因变量上的相互作用。当我不包括交互项时,模型就起作用了,当我包含交互项时,我得到了

"PerfectSeparationError: Perfect separation detected, results not available"

对于logistic回归,已经有一个关于完全分离的问题得到了解答,但这个问题特别涉及到模型中带有交互项的完全分离误差。在

这是我的数据 Dataframe

我的代码:

endog_cols = df.columns[1:3]

exog_cols = df.columns[4:8]

logit2 = sm.GLM(df[endog_cols], df[exog_cols], family = sm.families.Binomial()).fit()

Tags: columns模型df因素smcols因变量logistic