开始使用免费开始使用

最小二乘因子模型

正如您所看到的,2005—2010 年期间,季度最小收益与按揭拖欠率之间存在「负相关」。我们可以用 OLS 回归的因子模型更精确地量化这种关系。

您将比较 3 个因子模型,它们对应 3 个不同的季度「因变量」:平均收益、最小收益和平均波动率。「自变量」是按揭拖欠率。在回归摘要中,请查看系数的 t 统计量以判断统计显著性,并关注整体的 R-squared 评估拟合优度。

statsmodels.api 库可用别名 sm 调用。

本练习是课程的一部分

Python 中的定量风险管理

查看课程

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Add a constant to the regression
mort_del = sm.add_constant(mort_del)

# Create the regression factor model and fit it to the data
results = sm.____(____, mort_del).fit()

# Print a summary of the results
print(results.summary())
编辑并运行代码