问题描述
如何在python中执行逐步回归?SCIPY 中有 OLS 的方法,但我无法逐步进行.在这方面的任何帮助将是一个很大的帮助.谢谢.
How to perform stepwise regression in python? There are methods for OLS in SCIPY but I am not able to do stepwise. Any help in this regard would be a great help. Thanks.
我正在尝试构建线性回归模型.我有 5 个自变量并使用前向逐步回归,我的目标是选择变量以使我的模型具有最低的 p 值.以下链接解释了目标:
I am trying to build a linear regression model. I have 5 independent variables and using forward stepwise regression, I aim to select variables such that my model has the lowest p-value. Following link explains the objective:
再次感谢.
推荐答案
Trevor Smith 和我用 statsmodels 为线性回归编写了一个小前向选择函数:http://planspace.org/20150423-forward_selection_with_statsmodels/ 您可以轻松修改它以最小化 p 值,或者只需要多做一点工作即可根据 beta p 值进行选择.
Trevor Smith and I wrote a little forward selection function for linear regression with statsmodels: http://planspace.org/20150423-forward_selection_with_statsmodels/ You could easily modify it to minimize a p-value, or select based on beta p-values with just a little more work.
这篇关于Python 中的逐步回归的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!