温馨提示: 定期 清理浏览器缓存,可以获得最佳浏览体验。
New!
lianxh
命令发布了:
随时搜索推文、Stata 资源。安装命令如下:
. ssc install lianxh
详情参见帮助文件 (有惊喜):
. help lianxh
⛳ Stata 系列推文:
作者: 李硕清 (中山大学)
邮箱: 857532149@qq.com
目录
在估计参数的聚类标准误差时,必须考虑总样本内不同样本群之间的相关性。但是,在许多程序中是默认忽略这种依赖性的,这会使计算得出的 OLS 标准误差会大大低估真实的 OLS 标准误差。
为了解决这个问题,我们应该使用允许异方差或聚类误差相关性存在的聚类稳健标准误 (CRVE)。需要注意的是,该稳健标准误使用的前提假设是样本中的样本簇数量要相当大,一般来说要超过 30 组。
我们先来求在 OLS 下聚类误差的大小。假设模型数据被分为
其中,
在该模型下,OLS 估计量为
这个方差比基于 OLS 方法的残差独立同分布假设下所求的方差
为了解决低估的情况,可以使用聚类稳健误差估计 CRVE 方法。CRVE 方法以 G
当使用 CRVE 方法但 G 的数量较小 (小于 30) 时,如果使用传统的 Wald 检验来检验系数有效性,可能会产生过度拒绝的问题。具体来看,双边 Wald 检验的
其中,wcbregress
。
为了解决传统 Wald 检验过度拒绝的问题,很多计量学家提出了自己的想法。例如,Donald 和 Lang (2007) 选择不使用 OLS 估计量,而是新提出一个替代性的两步估计量,并使用 wcbregress
命令也使用了一种新的方法,即继续使用 CRVE 方法估计标准 OLS 估计量,但在计算参数有效性的时候提出全新的改进。
Bootstrap 的引入。Bootstrap 方法 (自助法) 是从原始样本生成大量伪样本,并且对于每个伪样本,计算相应的统计量。然后,使用该统计量在伪样本中的分布来推断原始样本统计量的分布。Bootstrap 的方法并不是单一的,它会根据需要计算的统计量、生产的伪样本、以及推断的方法进行调整。
多种统计方法的比较。对于聚类稳健参数的有效性判断,一般有下图所示的四大类方法、以及大类方法下相应的处理方法。经过蒙特卡罗模拟验证,研究人员发现,即使只有 6 个集群,使用 Wild Cluster Bootstrap 方法,得出的经验拒绝率非常接近理论值。
Source: Cameron A C, Gelbach J B, Miller D L. Bootstrap-based improvements for inference with clustered errors[J]. The Review of Economics and Statistics, 2008, 90(3): 414-427. -PDF-, -PDF2-, Table 1: Different Methods for Wald Test.
wcbregress
可以选择使用 CRVE 方法进行参数的稳健性求解,同时还会返回用 Wild Cluster Bootstrap 方法对参数进行的有效性检验的结果。这个命令依赖于 Stata 内置的 regress
命令,因此 regress
的大多数选项都与 wcbregress
兼容。
*命令安装
ssc install wcbregress, replace
*语法结构
wcbregress depvar varlist [if] [in] [weight] [, options]
depvar
:被解释变量;varlist
:不进入选择模型的解释变量;options
具体如下:
group(varname)
:用于生成各变量簇的变量名称;robust
:稳健地使用 CRVE 方法求解系数;vce(vcetype)
:获得稳健标准误;nonconstant(varname)
:进行无常数项回归;hascons
:使用用户提供的常数项进行回归;tsscons
:计算一系列常数项的平方和;level(#)
:设置置信区间,默认是 95%;seed(#)
:设置随机数种子;detail
:显示中间命令输出;rep(#)
:用于计算标准误差或置信区间的 bootstrap 复制数,默认是 500。
接下来,我们以 Stata 自带的「auto.dta」数据为例,来演示命令 wcbregress
的使用方法。相关设定如下:
. clear all
. sysuse auto.dta, clear
(1978 Automobile Data)
. wcbregress price mpg headroom trunk weight, group(rep78) level(99)
Wild Cluster Boostrap in progress (200 replications)
(each dot . indicates one replication)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
.................................................. 50
.................................................. 100
.................................................. 150
.................................................. 200
Wild Cluster Bootstrap Linear regression
Number of obs = 74.000
Replications = 200.000
R-squared = 0.323
Adj R-squared = 0.283
Root MSE = 2497.033
----------------------------------------------------------------------------
Panel A: Point Estimates and Wild Cluster Bootstrap Std. Err.
----------------------------------------------------------------------------
| Bootstrap Normalized
price | Coef. Std. Err. z P>|z| [ 99% Conf. Interval ]
----------+-----------------------------------------------------------------
mpg | -54.7915 66.9427 -0.82 0.413 -168.339 58.756
headroom |-726.5434 243.1408 -2.99 0.003 -1150.295 -302.792
trunk | 23.0425 104.3392 0.22 0.825 -150.260 196.345
weight | 2.0119 1.1985 1.68 0.093 -0.080 4.104
_cons |3114.9403 4283.5837 0.73 0.467 -4541.290 10771.170
----------------------------------------------------------------------------
Panel B: Wild Cluster Bootstrap t-tests and Confidence Intervals
----------------------------------------------------------------------------
| Bootstrap [ 99% Conf. Interval ]
price | P>|t*| [ Symmetric CI ] [ Asymmetric CI ]
----------+-----------------------------------------------------------------
mpg | 0.520 -177.168 67.585 -177.168 67.585
headroom | 0.030 -1471.480 18.393 -1471.480 18.393
trunk | 0.790 -336.623 382.708 -350.185 382.708
weight | 0.500 -6.348 10.372 -4.879 10.372
_cons | 0.560 -12662.700 18892.580 -13886.579 18892.580
----------------------------------------------------------------------------
* Disclaimer: This is a Beta version of the command. helloyzz@gmail.com
可以看出,wcbregress
命令使用 Wild Cluster Bootstrap 方法重复 200 次创建伪样本,并在 Panel A 报告相应的估计系数,以及 Bootstrap 标准差。与此同时,在 Panel B 里使用
将 Bootstrap 重复次数改为 50 次。
. wcbregress price mpg headroom trunk weight, group(rep78) rep(50) level(99)
Wild Cluster Boostrap in progress (50 replications)
(each dot . indicates one replication)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
.................................................. 50
Wild Cluster Bootstrap Linear regression
Number of obs = 74.000
Replications = 50.000
R-squared = 0.323
Adj R-squared = 0.283
Root MSE = 2497.033
----------------------------------------------------------------------------
Panel A: Point Estimates and Wild Cluster Bootstrap Std. Err.
----------------------------------------------------------------------------
| Bootstrap Normalized
price | Coef. Std. Err. z P>|z| [ 99% Conf. Interval ]
----------+-----------------------------------------------------------------
mpg | -54.7915 66.9427 -0.82 0.413 -168.075 58.492
headroom |-726.5434 243.1408 -2.99 0.003 -1107.982 -345.105
trunk | 23.0425 104.3392 0.22 0.825 -141.675 187.760
weight | 2.0119 1.1985 1.68 0.093 -0.016 4.039
_cons |3114.9403 4283.5837 0.73 0.467 -4327.558 10557.439
----------------------------------------------------------------------------
Panel B: Wild Cluster Bootstrap t-tests and Confidence Intervals
----------------------------------------------------------------------------
| Bootstrap [ 99% Conf. Interval ]
price | P>|t*| [ Symmetric CI ] [ Asymmetric CI ]
----------+-----------------------------------------------------------------
mpg | 0.680 -167.708 58.125 -167.708 58.125
headroom | 0.000 -1334.871 -118.216 -1334.871 -118.216
trunk | 0.880 -323.061 369.146 -350.185 369.146
weight | 0.360 -4.879 8.903 -2.962 8.903
_cons | 0.680 -11104.649 17334.530 -11104.649 17334.530
----------------------------------------------------------------------------
* Disclaimer: This is a Beta version of the command. helloyzz@gmail.com
可以看出,重复次数即使调为 50 次后,系数估计并没有发生变化,但是有效性检验的
添加稳健性估计选项和去常数项回归选项,同时展示系统存储的计算数据。
. wcbregress price mpg headroom trunk weight, group(rep78) rep(50) level(90) seed(2333) robust
Wild Cluster Boostrap in progress (50 replications)
(each dot . indicates one replication)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
.................................................. 50
Wild Cluster Bootstrap Linear regression
Number of obs = 74.000
Replications = 50.000
R-squared = 0.323
Adj R-squared = 0.283
Root MSE = 2497.033
---------------------------------------------------------------------------
Panel A: Point Estimates and Wild Cluster Bootstrap Std. Err.
---------------------------------------------------------------------------
| Bootstrap Normalized
price | Coef. Std. Err. z P>|z| [ 90% Conf. Interval ]
----------+----------------------------------------------------------------
mpg | -54.7915 66.9427 -0.82 0.413 -181.047 71.464
headroom |-726.5434 243.1408 -2.99 0.003 -1199.264 -253.823
trunk | 23.0425 104.3392 0.22 0.825 -180.287 226.372
weight | 2.0119 1.1985 1.68 0.093 -0.424 4.447
_cons |3114.9403 4283.5837 0.73 0.467 -5429.827 11659.708
---------------------------------------------------------------------------
Panel B: Wild Cluster Bootstrap t-tests and Confidence Intervals
---------------------------------------------------------------------------
| Bootstrap [ 90% Conf. Interval ]
price | P>|t*| [ Symmetric CI ] [ Asymmetric CI ]
----------+----------------------------------------------------------------
mpg | 0.680 -169.098 59.515 -167.024 59.515
headroom | 0.040 -1396.238 -56.849 -1284.111 -56.849
trunk | 0.960 -313.770 359.855 -313.770 359.855
weight | 0.480 -6.348 10.372 -4.879 10.372
_cons | 0.800 -10710.728 16940.609 -13886.579 16940.609
---------------------------------------------------------------------------
* Disclaimer: This is a Beta version of the command. helloyzz@gmail.com
. ereturn list
scalars:
e(N) = 74
e(r2) = .3225469262049001
e(r2_a) = .283274284245764
e(rmse) = 2497.033035550464
macros:
e(vcetype) : "Wild Cluster Bootstrap SE"
e(cmd) : "wcbregress"
e(title) : "Wild cluster bootstrap SE and T-tests for the linear regression"
e(Brep) : "50"
e(properties) : "b V"
matrices:
e(b) : 1 x 5
e(V) : 5 x 5
e(WCB_pvalue) : 1 x 5
e(WCB_V) : 1 x 5
functions:
e(sample)
可以看出,无常数项估计会对估计结果,以及有效性检验产生较大影响。在 Bootstrap 重复次数足够大的情况下,是否稳健地进行系数估计所得系数结果差别不大,但是会对有效性检验的
当所拥有的簇类数量较少的时候,原有聚类命令估计出的系数有效性很差。如何在簇类样本较少的情况下有效地估计系数,并避免在系数有效性检验时过度拒绝,是实证金融研究里一个重要的话题。
wcbregress
采用了 Wild Cluster Bootstrap 的自抽样方法,并使用
Note:产生如下推文列表的命令为:
lianxh 聚类 标准误 bootstrap 空间相关性, m
安装最新版lianxh
命令:
ssc install lianxh, replace
免费公开课
最新课程-直播课
专题 | 嘉宾 | 直播/回看视频 |
---|---|---|
⭐ 最新专题 | 文本分析、机器学习、效率专题、生存分析等 | |
研究设计 | 连玉君 | 我的特斯拉-实证研究设计,-幻灯片- |
面板模型 | 连玉君 | 动态面板模型,-幻灯片- |
面板模型 | 连玉君 | 直击面板数据模型 [免费公开课,2小时] |
⛳ 课程主页
⛳ 课程主页
关于我们
课程, 直播, 视频, 客服, 模型设定, 研究设计, stata, plus, 绘图, 编程, 面板, 论文重现, 可视化, RDD, DID, PSM, 合成控制法
等
连享会小程序:扫一扫,看推文,看视频……
扫码加入连享会微信群,提问交流更方便
✏ 连享会-常见问题解答:
✨ https://gitee.com/lianxh/Course/wikis
New!
lianxh
命令发布了:
随时搜索连享会推文、Stata 资源,安装命令如下:
. ssc install lianxh
使用详情参见帮助文件 (有惊喜):
. help lianxh