我正在关注statsmodels
教程中的第一个示例:
http://statsmodels.sourceforge.net/devel/
如何指定不使用常数项进行 ols 中的线性拟合?
# Fit regression model (using the natural log of one of the regressors)
results = smf.ols('Lottery ~ Literacy + np.log(Pop1831)', data=dat).fit()
我正在关注statsmodels
教程中的第一个示例:
http://statsmodels.sourceforge.net/devel/
如何指定不使用常数项进行 ols 中的线性拟合?
# Fit regression model (using the natural log of one of the regressors)
results = smf.ols('Lottery ~ Literacy + np.log(Pop1831)', data=dat).fit()
如运算符部分所示,您可以在公式字符串中使用“-1”来删除截距项:
results = smf.ols('Lottery ~ Literacy + np.log(Pop1831) - 1', data=dat).fit()