我尝试在dataset数组中使用add_constant()函数。在索引59处,它起作用(创建了列),但在索引60时,它没有被创建。最初,testmat59返回形状为(24,54),testmat60返回形状为(9,54)。下面是我运行add_constant函数时得到的结果:
In: Xnew = sm.add_constant(testmat[59])
Out:
const TRYSIL_PO TRYSIL_TA
6142 1 985.7 271.65
6143 1 984.9 271.85In: Xnew = sm.add_constant(testmat[60]):
Out:
TRYSIL_PO TRYSIL_TA
6166 983.6 272.75
6167 983.1 272.85我已经查过其他消息来源了,但这一条似乎还没有得到解决。你能解释一下吗?
发布于 2016-04-10 17:37:32
如果已经有一个带有add_constant()的列,即一个具有所有相同值的列,那么它似乎就不能工作。在我的dataset中是这样的(上面的示例(54列)中没有提到)。
解决方案是在add_constant()函数中添加add_constant选项,如下所示:
sm.add_constant(testmat[60], has_constant='add')更多信息:constant.html
https://stackoverflow.com/questions/36532529
复制相似问题