Stata连享会 主页 || 视频 || 推文 || 知乎 || Bilibili 站
温馨提示: 定期 清理浏览器缓存,可以获得最佳浏览体验。
New!
lianxh
命令发布了:
随时搜索推文、Stata 资源。安装:
. ssc install lianxh
详情参见帮助文件 (有惊喜):
. help lianxh
连享会新命令:cnssc
,ihelp
,rdbalance
,gitee
,installpkg
⛳ Stata 系列推文:
作者:郭盼亭 (厦门大学)
邮箱:gpting2020@163.com
目录
事件研究法 (Event Study) 由 Ball 和 Brown (1968) 以及 Fama 等 (1969) 开创。其原理是根据研究目的选择某一特定事件,研究事件发生前后样本股票收益率的变化,进而解释特定事件对样本股票价格变化与收益率的影响。其目的是检验事件发生前后价格变化或价格对披露信息的反应程度。
事件研究法以有效市场假说为基础,即股票价格反映了所有已知的公共信息,由于投资者是理性的,投资者对新信息的反应也是理性的。因此,在样本股票实际收益中剔除假定某个事件没有发生而估计出来的正常收益 (normal return),就可以得到异常收益 (abnormal return)。异常收益可以衡量股价对事件发生或信息披露异常反应的程度。
事件日 (Event date):特定事件发生的日期 (
事件窗口期 (Event window):对事件涉及到的股票价格进行考察的时间段 ([
估计窗口 (Estimation window):估计窗口一般选择为事件发生前一段时间,通常是事件发生前 210 个交易日至前 11 个交易日 [-210, -10]。估计窗口与事件窗口不可有交集。
正常收益 (Normal Returns):为了考察特定事件对公司股价的影响,我们首先需要知道,如果没有该事件发生,股票收益率应该是多少,这也就是我们需要估计正常收益率的原因。
异常收益率 (Abnormal Returns,ARs):每只股票实际收益率与正常收益率的差值,异常收益率能够反映该事件的经济影响。
累积异常收益率 (Cumulative abnormal returns,CARs): 每只股票在事件窗口内异常收益率的简单加总,最常见的是 CAR(-1, +1) 和 CAR(-2, +2),正负的天数可根据研究需要进行相应调整。
事件研究法的核心是首先采用模型估计正常收益率,然后计算异常收益率并加总异常收益率 (CAR),最后检验每只股票的累积异常收益是否在统计上异于零,以便判断事件的发生是否对股价产生了显著的影响。
正常收益率估计模型有大致 5 种,分别是:
以市场模型为例,
得到估计系数
平均异常收益率是针对某一时点、对所有公司的异常收益率求平均,计算方式如下所示:
累积异常收益率是计算公司
平均累积异常收益率,也即在特定时点
计算出累积异常收益率之后,最后需要检验每只股票的累积异常收益是否在统计上异于零,以便判断事件的发生是否对股价产生了显著的影响。
eventcoefplot
命令运行回归并生成用于事件研究分析的图表,可以设定多种选项进行比较,以及样本稳健性检验。在事件研究的背景下,研究人员经常需要对控制不同变量、固定效应或聚集标准误的回归设定进行比较。eventcoefplot
命令提供了一种简单的方法来比较最多三种设定:
multitest
:允许通过一次包括一组控件来比较任意数量的组;leaveoneouttest
:允许通过在同一时间遗漏一个控制变量来检查估计的稳健性;perturbationtest
:检查结果不是由特定的子样本主导的,包括子样本结果异质性的检验结果。* 命令安装
ssc install eventcoefplot, replace
* 命令语法
eventcoefplot varname [if] [in], window(varlist) [command event(varname)
gapname(string) noconstant level(#) absorb#(varlist) controls#(varlist)
cluster#(varname) vce#(robust) aweight#(varname) fweight#(varname)
display multitest(globalsnames) tuplestest(varlist) leaveoneouttest(varlist)
perturbationtest(varname)]
其中,基础选项:
varname
:被解释变量;varlist
:解释变量,例如 window(period_-2 period-1 period_0 period_1 period_2)
;command
:推荐第一次使用该命令的用户加入此选项,可以展示回归使用的命令;event(varname)
:包含在窗口中的事件;gapname(string)
:系数的标签;noconstant
:不包含常数项;level(#)
:置信区间,默认水平是 (95%)。进行不同的模型对比时用到的选项:
absorb#(varlist)
:回归中包含的固定效应;controls#(varlist)
:回归中包含的控制变量;cluster#(varname)
:聚类标准误;vce#(robust)
:稳健标准误;aweight#(varname)
:设置分析权数,用在加权最小二乘回归以及类似的估计程序中;fweight#(varname)
:设置频数权数,用以对重复观测案例计数,频数权数必须是整数。稳健性检验选项:
display
:用于检验的时候,将具体的回归结果展示出来;multitest(globalsnames)
:分别绘制包括列表中的每一组控制变量的回归图;tuplestest(varlist)
:分别绘制包含 varlist
中变量的所有可能组合的回归图;leaveoneouttest(varlist)
:绘制剔除列表中某个控制变量的回归图;perturbationtest(varname)
:根据 #
变量的 levelsof()
每次排除一个 (类) 样本,绘制相应的回归图。绘图选项:
speccolor#(color)
:改变回归 #
的颜色;symbols
:改变不同回归模型的符号;symbol#
:改变回归模型 #
的符号,可以和 symbols
同时使用;testcicolor(color)
:设置检验的置信区间的颜色;testcoecolor(color)
:设置检验的系数的颜色;offset(filename)
:设置基本比较模型的偏移量;legend(filename)
:设置图例;{y|x}title(string)
:设置轴标题;{y|x}label(string)
:设置轴标签;{y|x}line(string)
:添加 xlines
或 ylines
;{y|x}size(string)
:调节图形的长度和高度。保存结果选项:
savegraph(file)
:保存所有表格,文件格式必须为 path/filename.csv;savetex(file)
:以 .tex 格式保存表格。
下面我们用一个来自 NLS 数据库的面板数据来检验此命令。NLS 数据库是具有全国代表性的调查,随着时间的推移跟踪来自特定出生群体的相同样本。这些调查收集了有关劳动力市场活动、教育、生育、项目参与、健康等方面的数据。其主要变量如下:
. * 导入数据并做简单处理
. webuse nlswork, clear
. keep if inlist(year, 69, 71, 73, 75, 77) //原始数据处理
. gen pre_2=year==69
. gen pre_1=year==71 //估计窗口
. gen post_1=year==75
. gen post_2=year==77 //事件窗口
将 ln_wage 对估计窗口和事件窗口进行回归,同时控制种族、出生年份、是否为大学毕业生、是否为南方人等变量,不包含常数项。
. eventcoefplot ln_wage, window(pre_2 pre_1 post_1 post_2) noconstant ///
> legend(off) command controls(race birth_yr collgrad south)
HDFE Linear regression Number of obs = 9,375
Absorbing 1 HDFE group F( 8, 9366) = 244.95
Prob > F = 0.0000
R-squared = 0.1730
Adj R-squared = 0.1723
Within R-sq. = 0.1730
Root MSE = 0.3799
------------------------------------------------------------------------------
ln_wage | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
pre_2 | -0.072 0.014 -5.12 0.000 -0.099 -0.044
pre_1 | -0.038 0.012 -3.05 0.002 -0.062 -0.013
post_1 | 0.003 0.012 0.28 0.778 -0.020 0.027
post_2 | 0.069 0.012 5.82 0.000 0.046 0.092
race | -0.048 0.008 -5.76 0.000 -0.065 -0.032
birth_yr | -0.025 0.001 -18.37 0.000 -0.028 -0.022
collgrad | 0.315 0.012 26.23 0.000 0.291 0.338
south | -0.181 0.008 -21.94 0.000 -0.197 -0.165
------------------------------------------------------------------------------
根据上述结果可知,在控制了种族、出生年份、是否为大学毕业生、是否为南方人等控制变量之后,pre_2、pre_1 期的系数显著为负,post_2 期的系数显著为正。假如需要在可视化图形中显示出以 post_1 期之前一期的估计为基准线,加入 event(post_1)
选项即可实现。
. eventcoefplot ln_wage, window(pre_2 pre_1 post_1 post_2) noconstant ///
> legend(off) command controls(race birth_yr collgrad south) ///
> event(post_1) xline(3, lpattern(dash) lcolor(gray))
HDFE Linear regression Number of obs = 9,375
Absorbing 1 HDFE group F( 8, 9366) = 244.95
Prob > F = 0.0000
R-squared = 0.1730
Adj R-squared = 0.1723
Within R-sq. = 0.1730
Root MSE = 0.3799
------------------------------------------------------------------------------
ln_wage | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
pre_2 | -0.072 0.014 -5.12 0.000 -0.099 -0.044
pre_1 | -0.038 0.012 -3.05 0.002 -0.062 -0.013
post_1 | 0.003 0.012 0.28 0.778 -0.020 0.027
post_2 | 0.069 0.012 5.82 0.000 0.046 0.092
race | -0.048 0.008 -5.76 0.000 -0.065 -0.032
birth_yr | -0.025 0.001 -18.37 0.000 -0.028 -0.022
collgrad | 0.315 0.012 26.23 0.000 0.291 0.338
south | -0.181 0.008 -21.94 0.000 -0.197 -0.165
------------------------------------------------------------------------------
为了进一步美化事件研究分析结果的可视化图形,可以进一步对标签进行命名,绘图时将自动把
. * 给标签命名后, 绘图的 x 轴坐标将自动显示为标签值
. label var pre_2 "-3"
. label var pre_1 "-2"
. label var post_1 "0"
. label var post_2 "1"
. eventcoefplot ln_wage, window(pre_2 pre_1 post_1 post_2) noconstant ///
> legend(off) command controls(race birth_yr collgrad south) ///
> event(post_1) xline(3, lpattern(dash) lcolor(gray))
将几组控制不同变量的事件研究分析结果画到一张图表里,来进行不同模型的对比,可以使用选项 controls#(varlist)
。
. eventcoefplot ln_wage, window(pre_2 pre_1 post_1 post_2) noconstant ///
> event(post_1) gapname(-1) xline(3, lpattern(dash) lcolor(gray)) ///
> command controls1(race birth_yr collgrad south) speccolor1(black) ///
> controls2(race birth_yr collgr) speccolor2(red) vce2(robust)
reghdfe ln_wage pre_2 pre_1 post_1 post_2 race birth_yr collgrad south,
noabsorb noconstant
HDFE Linear regression Number of obs = 9,375
Absorbing 1 HDFE group F( 8, 9366) = 244.95
Prob > F = 0.0000
R-squared = 0.1730
Adj R-squared = 0.1723
Within R-sq. = 0.1730
Root MSE = 0.3799
------------------------------------------------------------------------------
ln_wage | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
pre_2 | -0.072 0.014 -5.12 0.000 -0.099 -0.044
pre_1 | -0.038 0.012 -3.05 0.002 -0.062 -0.013
post_1 | 0.003 0.012 0.28 0.778 -0.020 0.027
post_2 | 0.069 0.012 5.82 0.000 0.046 0.092
race | -0.048 0.008 -5.76 0.000 -0.065 -0.032
birth_yr | -0.025 0.001 -18.37 0.000 -0.028 -0.022
collgrad | 0.315 0.012 26.23 0.000 0.291 0.338
south | -0.181 0.008 -21.94 0.000 -0.197 -0.165
------------------------------------------------------------------------------
reghdfe ln_wage pre_2 pre_1 post_1 post_2 race birth_yr collgr,
noabsorb vce(robust) noconstant
HDFE Linear regression Number of obs = 9,376
Absorbing 1 HDFE group F( 7, 9368) = 197.23
Prob > F = 0.0000
R-squared = 0.1305
Adj R-squared = 0.1299
Within R-sq. = 0.1305
Root MSE = 0.3895
------------------------------------------------------------------------------
| Robust
ln_wage | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
pre_2 | -0.068 0.014 -4.96 0.000 -0.094 -0.041
pre_1 | -0.036 0.013 -2.82 0.005 -0.061 -0.011
post_1 | -0.001 0.012 -0.05 0.959 -0.025 0.024
post_2 | 0.063 0.013 4.97 0.000 0.038 0.088
race | -0.090 0.008 -10.76 0.000 -0.107 -0.074
birth_yr | -0.024 0.001 -16.37 0.000 -0.027 -0.021
collgrad | 0.329 0.012 26.59 0.000 0.305 0.353
------------------------------------------------------------------------------
其中,黑色线表示控制了种族、出生年份、是否是大学毕业生、是否为南方人等变量之后的事件研究分析结果。红色线表示的是控制种族、出生年份、是否是大学毕业生等变量之后的事件研究分析结果。根据回归结果和可视化图形均可以看出,这两组研究在控制了不同的变量之后,pre_2、pre_1 的系数都是显著为负值,post_2 的系数显著为正值,post_1 的系数不显著。
我们可以再做一种包含固定效应的检验,主要加入的选项是 absorb#(varlist)
,并使用选项 legend(filename)
设置图例。
. eventcoefplot ln_wage, window(pre_2 pre_1 post_1 post_2) noconstant ///
> event(post_1) gapname(-1) xline(3, lpattern(dash) lcolor(gray)) ///
> command symbols controls1(race birth_yr collgrad south) vce1(robust) ///
> controls2(race birth_yr collgrad) absorb2(idcode) vce2(robust) ///
> controls3(race birth_yr collgrad south) absorb3(idcode occ) vce3(robust) ///
> legend(1 "Baseline" 2 "ID FE's" 3 "ID + Occupation FE's")
reghdfe ln_wage pre_2 pre_1 post_1 post_2 race birth_yr collgrad south,
noabsorb vce(robust) noconstant
HDFE Linear regression Number of obs = 9,375
Absorbing 1 HDFE group F( 8, 9366) = 233.25
Prob > F = 0.0000
R-squared = 0.1730
Adj R-squared = 0.1723
Within R-sq. = 0.1730
Root MSE = 0.3799
------------------------------------------------------------------------------
| Robust
ln_wage | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
pre_2 | -0.072 0.013 -5.39 0.000 -0.098 -0.046
pre_1 | -0.038 0.012 -3.01 0.003 -0.062 -0.013
post_1 | 0.003 0.012 0.28 0.783 -0.020 0.027
post_2 | 0.069 0.012 5.56 0.000 0.045 0.093
race | -0.048 0.008 -6.09 0.000 -0.064 -0.033
birth_yr | -0.025 0.001 -17.67 0.000 -0.028 -0.022
collgrad | 0.315 0.012 25.63 0.000 0.291 0.339
south | -0.181 0.008 -22.73 0.000 -0.197 -0.165
------------------------------------------------------------------------------
reghdfe ln_wage pre_2 pre_1 post_1 post_2 race birth_yr collgrad,
absorb(idcode) vce(robust) noconstant
HDFE Linear regression Number of obs = 8,498
Absorbing 1 HDFE group F( 4, 5871) = 69.50
Prob > F = 0.0000
R-squared = 0.7126
Adj R-squared = 0.5841
Within R-sq. = 0.0522
Root MSE = 0.2650
------------------------------------------------------------------------------
| Robust
ln_wage | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
pre_2 | -0.093 0.011 -8.11 0.000 -0.115 -0.070
pre_1 | -0.040 0.010 -4.19 0.000 -0.059 -0.022
post_1 | 0.028 0.009 3.25 0.001 0.011 0.045
post_2 | 0.096 0.010 10.06 0.000 0.077 0.115
race | 0.000 (omitted)
birth_yr | 0.000 (omitted)
collgrad | 0.000 (omitted)
------------------------------------------------------------------------------
Absorbed degrees of freedom:
-----------------------------------------------------+
Absorbed FE | Categories - Redundant = Num. Coefs |
-------------+---------------------------------------|
idcode | 2623 0 2623 |
-----------------------------------------------------+
reghdfe ln_wage pre_2 pre_1 post_1 post_2 race birth_yr collgrad south,
absorb(idcode occ) vce(robust) noconstant
HDFE Linear regression Number of obs = 8,477
Absorbing 2 HDFE groups F( 5, 5843) = 45.84
Prob > F = 0.0000
R-squared = 0.7396
Adj R-squared = 0.6223
Within R-sq. = 0.0444
Root MSE = 0.2525
------------------------------------------------------------------------------
| Robust
ln_wage | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
pre_2 | -0.094 0.011 -8.58 0.000 -0.116 -0.073
pre_1 | -0.036 0.009 -3.94 0.000 -0.053 -0.018
post_1 | 0.011 0.008 1.31 0.191 -0.005 0.027
post_2 | 0.077 0.009 8.21 0.000 0.058 0.095
race | 0.000 (omitted)
birth_yr | 0.000 (omitted)
collgrad | 0.000 (omitted)
south | -0.057 0.026 -2.20 0.028 -0.108 -0.006
------------------------------------------------------------------------------
Absorbed degrees of freedom:
-----------------------------------------------------+
Absorbed FE | Categories - Redundant = Num. Coefs |
-------------+---------------------------------------|
idcode | 2618 0 2618 |
occ_code | 12 1 11 |
-----------------------------------------------------+
在以上回归结果中,第一个是基准回归,第二个是设定 idcode 为固定效应之后的回归结果。结果显示种族、出生年份、是否为大学毕业生和固定效应可能存在共线性而被从模型中忽略。第三个是设定 idcode、occ_code 为固定效应之后,结果同样显示种族、出生年份、是否为大学毕业生和固定效应可能存在共线性而被从模型中忽略。
除了添加固定效应,科研人还经常需要控制不同的控制变量,来验证结论的稳健性。此时 tuplestest(varlist)
选项就派上用场了。tuplestest(varlist)
这个选项可以列举所有放入括号中变量的组合进行检验,并且如果需要查看具体的回归结果,可以将选项 command
换成 display
。
. * 稳健性检验: Tuplestest 检验
. eventcoefplot ln_wage, window(pre_2 pre_1 post_1 post_2) noconstant ///
> legend(off) event(post_1) xline(3, lpattern(dash) lcolor(gray)) ///
> display controls(age) tuplestest(race birth_yr collgrad south)
leaveoneouttest(varlist)
也是一个用于稳健性检验选项,它是通过逐一去除括号中的一个变量,形成不同的控制变量组合进行检验的。
. * Leaveoneouttest 检验, 可以逐一去除一个变量进行检验
. eventcoefplot ln_wage, window(pre_2 pre_1 post_1 post_2) noconstant ///
> legend(off) event(post_1) xline(3, lpattern(dash) lcolor(gray)) ///
> command controls(age) leaveoneouttest(race birth_yr collgrad south)
multitest(globalsnames)
也是一个用于稳健性检验的选项,可以提前利用全局变量设定,同时包含一系列控制变量。
. * Multitest检验, 可以同时包含一系列的控制变量, 不过需要提前利用全局变量设定
. global cov1 "race birth_yr"
. global cov2 "collgrad south"
. eventcoefplot ln_wage, window(pre_2 pre_1 post_1 post_2) noconstant ///
> legend(off) event(post_1) xline(3, lpattern(dash) lcolor(gray)) ///
> command controls(age) multitest(cov1 cov2)
不同于上述介绍的几个选项,通过加入不同组合的控制变量来进行稳健性检验,Perturbationtest(#)
根据 # 变量的 levelsof()
每次排除一个 (类) 样本,以此来进行稳健性检验。
. eventcoefplot ln_wage, window(pre_2 pre_1 post_1 post_2) noconstant ///
> legend(off) event(post_1) xline(3, lpattern(dash) lcolor(gray)) ///
> command controls(age race birth_yr collgrad south) ///
> perturbationtest(age) testcicolor(navy)
Note:产生如下推文列表的 Stata 命令为:
lianxh 事件研究, m
安装最新版lianxh
命令:
ssc install lianxh, replace
免费公开课
最新课程-直播课
专题 | 嘉宾 | 直播/回看视频 |
---|---|---|
⭐ 最新专题 | 文本分析、机器学习、效率专题、生存分析等 | |
研究设计 | 连玉君 | 我的特斯拉-实证研究设计,-幻灯片- |
面板模型 | 连玉君 | 动态面板模型,-幻灯片- |
面板模型 | 连玉君 | 直击面板数据模型 [免费公开课,2小时] |
⛳ 课程主页
⛳ 课程主页
关于我们
课程, 直播, 视频, 客服, 模型设定, 研究设计, stata, plus, 绘图, 编程, 面板, 论文重现, 可视化, RDD, DID, PSM, 合成控制法
等
连享会小程序:扫一扫,看推文,看视频……
扫码加入连享会微信群,提问交流更方便
✏ 连享会-常见问题解答:
✨ https://gitee.com/lianxh/Course/wikis
New!
lianxh
和songbl
命令发布了:
随时搜索连享会推文、Stata 资源,安装命令如下:
. ssc install lianxh
使用详情参见帮助文件 (有惊喜):
. help lianxh