本文整理汇总了Python中statsmodels.regression.linear_model.OLS.summary2方法的典型用法代码示例。如果您正苦于以下问题:Python OLS.summary2方法的具体用法?Python OLS.summary2怎么用?Python OLS.summary2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类statsmodels.regression.linear_model.OLS
的用法示例。
在下文中一共展示了OLS.summary2方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_OLSsummary_rsquared_label
# 需要导入模块: from statsmodels.regression.linear_model import OLS [as 别名]
# 或者: from statsmodels.regression.linear_model.OLS import summary2 [as 别名]
def test_OLSsummary_rsquared_label(self):
# Check that the "uncentered" label is correctly added after rsquared
x = [1, 5, 7, 3, 5, 2, 5, 3]
y = [6, 4, 2, 7, 4, 9, 10, 2]
reg_with_constant = OLS(y, x, hasconst=True).fit()
assert 'R-squared:' in str(reg_with_constant.summary2())
assert 'R-squared:' in str(reg_with_constant.summary())
reg_without_constant = OLS(y, x, hasconst=False).fit()
assert 'R-squared (uncentered):' in str(reg_without_constant.summary2())
assert 'R-squared (uncentered):' in str(reg_without_constant.summary())
示例2: test_ols_summary_rsquared_label
# 需要导入模块: from statsmodels.regression.linear_model import OLS [as 别名]
# 或者: from statsmodels.regression.linear_model.OLS import summary2 [as 别名]
def test_ols_summary_rsquared_label():
# Check that the "uncentered" label is correctly added after rsquared
x = [1, 5, 7, 3, 5, 2, 5, 3]
y = [6, 4, 2, 7, 4, 9, 10, 2]
reg_with_constant = OLS(y, add_constant(x)).fit()
r2_str = 'R-squared:'
with pytest.warns(UserWarning):
assert r2_str in str(reg_with_constant.summary2())
with pytest.warns(UserWarning):
assert r2_str in str(reg_with_constant.summary())
reg_without_constant = OLS(y, x, hasconst=False).fit()
r2_str = 'R-squared (uncentered):'
with pytest.warns(UserWarning):
assert r2_str in str(reg_without_constant.summary2())
with pytest.warns(UserWarning):
assert r2_str in str(reg_without_constant.summary())