让统计模型在系数 t 检验中使用异方差校正标准误差 [英] Getting statsmodels to use heteroskedasticity corrected standard errors in coefficient t-tests

查看:111
本文介绍了让统计模型在系数 t 检验中使用异方差校正标准误差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究 的 APIstatsmodels.regression.linear_model.RegressionResults 并找到了如何检索不同风格的异方差校正标准错误(通过HC0_se 等属性)但是,我不能很清楚如何对系数进行 t 检验以使用这些校正后的标准误差.有没有办法在 API 中执行此操作,还是必须手动执行此操作?如果是后者,您能否就如何使用 statsmodels 结果提出任何指导建议?

I've been digging into the API of statsmodels.regression.linear_model.RegressionResults and have found how to retrieve different flavors of heteroskedasticity corrected standard errors (via properties like HC0_se, etc.) However, I can't quite figure out how to get the t-tests on the coefficients to use these corrected standard errors. Is there a way to do this in the API, or do I have to do it manually? If the latter, can you suggest any guidance on how to do this with statsmodels results?

推荐答案

线性模型、离散模型和GLM的fit方法,取一个cov_type和一个cov_kwds 用于指定稳健协方差矩阵的参数.这将附加到结果实例并用于汇总表中报告的所有推理和统计数据.

The fit method of the linear models, discrete models and GLM, take a cov_type and a cov_kwds argument for specifying robust covariance matrices. This will be attached to the results instance and used for all inference and statistics reported in the summary table.

不幸的是,文档并没有以适当的方式真正显示这一点.根据选项实际选择三明治的辅助方法显示了选项和必需的参数:http://statsmodels.sourceforge.net/devel/generated/statsmodels.regression.linear_model.OLS.fit.html

Unfortunately, the documentation doesn't really show this yet in an appropriate way. The auxiliary method that actually selects the sandwiches based on the options shows the options and required arguments: http://statsmodels.sourceforge.net/devel/generated/statsmodels.regression.linear_model.OLS.fit.html

例如,估计一个 OLS 模型并使用 HC3 协方差矩阵可以通过

For example, estimating an OLS model and using HC3 covariance matrices can be done with

model_ols = OLS(...)
result = model_ols.fit(cov_type='HC3')
result.bse
result.t_test(....)

一些三明治需要额外的参数,例如集群稳健标准错误,可以通过以下方式选择,假设 mygroups 是一个包含组标签的数组:

Some sandwiches require additional arguments, for example cluster robust standard errors, can be selected in the following way, assuming mygroups is an array that contains the groups labels:

results = OLS(...).fit(cov_type='cluster', cov_kwds={'groups': mygroups}
results.bse
...

一些稳健的协方差矩阵在没有检查的情况下对数据做出额外的假设.例如异方差和自相关鲁棒标准误差或 Newey-West,HAC,标准误差假设一个顺序时间序列结构.一些面板数据稳健标准误差还假设时间序列由个人叠加.

Some robust covariance matrices make additional assumptions about the data without checking. For example heteroscedasticity and autocorrelation robust standard errors or Newey-West, HAC, standard errors assume a sequential time series structure. Some panel data robust standard errors also assume stacking of the time series by individuals.

一个单独的选项 use_t 可用于指定默认情况下是否应使用 t 和 F 或正态和卡方分布进行 Wald 检验和置信区间.

A separate option use_t is available to specify whether the t and F or the normal and chisquare distributions should be used by default for Wald tests and confidence intervals.

这篇关于让统计模型在系数 t 检验中使用异方差校正标准误差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆