“生命线”中的 Cox PH 模型 - 违反了虚拟变量的假设

Cox PH model in `lifelines` - violated assumptions for dummy variables

我正在使用 lifelines 库来估计 Cox PH 模型。对于回归,我有许多分类特征,我对这些特征进行单热编码并删除每个特征的一列以避免多重共线性问题(虚拟变量陷阱)。我没有附上代码,因为示例可能与文档 here 中给出的示例类似。

通过 运行 cph.check_assumptions(data) 我收到的信息表明每个虚拟变量都违反了假设:

Variable 'dummy_a' failed the non-proportional test: p-value is 0.0063.
Advice: with so few unique values (only 2), you can try `strata=['dummy_a']` in the call in `.fit`. See documentation in link [A] and [B] below.

我应该如何理解关于单个分类特征的多个虚拟变量的建议?我应该将它们全部添加到分层中吗?

如有任何意见,我将不胜感激:)

@abu,你的问题在文档中提出了一个明显的差距——如果虚拟变量违反比例测试怎么办。在这种情况下,我建议 not 虚拟化变量,并将原始列添加为分层变量,例如:fit(..., strata=['dummy'])