【发布时间】:2020-07-07 14:10:05
【问题描述】:
我拟合了两个回归模型,一个只有 1 个预测变量,另一个有 3 个预测变量。现在我想比较这两个模型。我怎样才能做到这一点?我知道如何在 R 中做到这一点,但不知道如何在 python 中做到这一点。这是 R 中用于比较两个模型的代码 -
anova(albumSales.2, albumSales.3)
结果 -
Model 1: sales ~ adverts
Model 2: sales ~ adverts + airplay + attract
Res.Df RSS Df Sum of Sq F Pr(>F)
1 198 862264
2 196 434575 2 427690 96.447 < 2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
基于上述结果,我们可以看到,与 albumSales.2 相比,albumSales.3 显着提高了模型对数据的拟合度,F(2, 196) = 96.44, p
我如何在 python 中做到这一点?
【问题讨论】:
标签: python statistics statsmodels anova