不同层级的交互项
当有 3 个自变量时,交互项的指定方式会显著增加。您可以不指定任何交互项。您也可以指定两两交互项,从而获得每一对变量的模型系数。第三种做法是包含所有交互项,也就是 3 个两两交互项加上 3 个自变量三者同时的交互项。
随着自变量数量继续增加,可能的交互项数量会快速增长。
taiwan_real_estate 已提供。
本练习是课程的一部分
Python 中级回归:使用 statsmodels
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Model price vs. no. of conv. stores, sqrt dist. to MRT station & house age, no global intercept, no interactions
mdl_price_vs_all_no_inter = ____
# See the result
print(mdl_price_vs_all_no_inter.params)