小编파워뿡*_*뿡뿡이的帖子

我怎样才能在Python中测试wald?

我想测试一个假设“截距 = 0,beta = 1”,所以我应该进行 Wald 测试并使用模块“statsmodel.formula.api”。

但我不确定在进行 Wald 测试时哪个代码是正确的。

from statsmodels.datasets import longley
import statsmodels.formula.api as smf
data = longley.load_pandas().data

hypothesis_0 = '(Intercept = 0, GNP = 0)'
hypothesis_1 = '(GNP = 0)'
hypothesis_2 = '(GNP = 1)'
hypothesis_3 = '(Intercept = 0, GNP = 1)'
results = smf.ols('TOTEMP ~ GNP', data).fit()
wald_0 = results.wald_test(hypothesis_0)
wald_1 = results.wald_test(hypothesis_1)
wald_2 = results.wald_test(hypothesis_2)
wald_3 = results.wald_test(hypothesis_3)

print(wald_0)
print(wald_1)
print(wald_2)
print(wald_3)

results.summary()
Run Code Online (Sandbox Code Playgroud)

我一开始认为假设_3 是正确的。

但假设_1 的结果与回归的 F 检验相同,表示假设“截距 = 0 且 beta …

python-3.x statsmodels

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

python-3.x ×1

statsmodels ×1