这是我的代码片段:import statsmodels.api as smmerged 是一个作为回归变量的 Pandas 数据框,memoscore 是一个将一个变量作为我的因变量的 Pandas 数据框.以下工作顺利且即时:model = sm.OLS(np.array(memoscore), np.array(sm.add_constant(merged)))结果 = model.fit()然后我拿了memoscore的日志,以下仍然立即生效:memoscore_ln = np.log(memoscore)模型 = sm.OLS(np.array(memoscore_ln), np.array(sm.add_constant(merged))但它永远卡在这里:results = model.fit()任何人都可以提出原因和/或如何解决这个问题吗?在此先感谢您! 解决方案 我将数据导出到 R 并使用 memoscore 运行相同的 OLS 并记录了 memoscore 作为依赖变量,它就像一个魅力.仍然不知道 statsmodels 有什么问题,但至少我了解到 R 是执行此类简单回归任务的首选软件.I am using statsmodels.api for some simple OLS regression... And somehow every time I ran my script it got stuck at model.fit and I couldn't figure out why.Here is a snippet of my code:import statsmodels.api as smmerged is a pandas data frame as regressors and memoscore is a pandas data frame of one variable as my dependent variable. The following worked smoothly and instantly:model = sm.OLS(np.array(memoscore), np.array(sm.add_constant(merged)))results = model.fit()Then I took the log of memoscore, the following still worked instantly:memoscore_ln = np.log(memoscore)model = sm.OLS(np.array(memoscore_ln), np.array(sm.add_constant(merged))But it got stuck here forever:results = model.fit()Could anyone kindly suggest reason why and/or how to get around that? Thank you so much in advance! 解决方案 I exported my data to R and ran the same OLS using memoscore and logged memoscore as the dependent variable, it worked like a charm. Still don't know what's wrong with statsmodels, but at least I learnt R is the go-to software for such easy regression tasks. 这篇关于statsmodels OLS 拟合计算时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-22 07:50