Stata连享会 主页 || 视频 || 推文 || 知乎 || Bilibili 站
温馨提示: 定期 清理浏览器缓存,可以获得最佳浏览体验。
New!
lianxh
命令发布了:
随时搜索推文、Stata 资源。安装:
. ssc install lianxh
详情参见帮助文件 (有惊喜):
. help lianxh
连享会新命令:cnssc
,ihelp
,rdbalance
,gitee
,installpkg
⛳ Stata 系列推文:
作者:吕可夫 (厦门大学)
邮箱:lvkefu@163.com
目录
在许多研究中,非时变变量在结构方程中扮演着重要的角色。例如在劳动经济学、卫生经济学等领域中,学者们热衷于讨论非时变变量 (如教育、性别、国籍、种族和宗教背景) 可能导致的经济后果。
需要注意的是,这些研究在开展过程中或多或少会面临一些估计问题:
值得一提的是,一种新的两阶段估计程序 xtseqreg
,可以在不依赖正交性假设的情况下估计非时变变量的系数 (Kripfganz1 和 Schwarz,2019)。
xtseqreg
命令的主要目的是估计带有非时变变量的线性 (动态) 面板数据模型。具体估计流程可分为以下两个步骤:
以如下动态面板模型为例:
其中个体
实现该两阶段估计方法需要满足两条假设:
在第一阶段里,我们先把非时变变量与个体固定效应合并为
在满足假设 1 和假设 2 的情况下,一阶段方程可使用多种常规估计方法,例如 Hsiao 等 (2002) 的 QML 估计量,Arellano 和 Bond (1991)、以及 Blundell 和 Bond (1998) 基于线性矩条件的 GMM 估计量,Ahn 和 Schmidt (1995) 基于非线性矩条件的 GMM 估计量等。
接下来将一阶段估计的残差提取出来,采用如下水平方程回归即可得到非时变变量的估计系数:
此外,上述两个阶段均可以使用工具变量解决自变量的内生性问题。在第二阶段,本方法纠正了通常的标准误,标准误修正也是这个新命令的主要贡献之一。
另外,xtseqreg
命令也可以用于估计常规 IV/GMM 单阶段。但本命令并非要替代以往命令,在某种程度上,其他命令包含一些本命令所不能实现的功能,但是本命令相比之下提供了额外的灵活性,且实现了标准误的校正。
*命令安装
cnssc install xtseqreg, replace
*命令语法
xtseqreg depvar [(indepvars1)] [indepvars2] [if] [in] [, options]
options
介绍:
first(first_spec)
:指定第一阶段估算结果;both
:指定第一阶段估算结果;iv(iv_spec)
:普通工具变量,可指定多个;gmmiv(gmmiv_spec)
:GMM 估计工具变量,可指定多个;wmatrix(wmat_spec)
:指定初始权重矩阵;twostep
:两步法估计;teffects
:纳入时间效应;noconstant
:无截距项;vce(vcetype)
:vcetype
可以是 conventional
、ec
、robust
或 cluster-clustvar
;combine
:合并两个方程的估计结果;level(#)
:设定置信水平,默认 95%;noheader
:不显示标题;notable
:不显示系数表;noomitted
:不显示省略的变量。
本文案例数据为一个劳动-收入领域的面板数据。我们关心的被解释变量是 lwage,即对数工资,id 和 t 则分别对应面板的横截面和时间指标。此外数据中包含了大量不随时间变化的变量,例如是否为黑人 blk、性别 fem 等等。固定效应面板回归通常无法估计这些非时变变量。
. webuse psidextract, clear
. des
Contains data from https://www.stata-press.com/data/r17/psidextract.dta
Observations: 4,165
Variables: 22 18 Aug 2020 11:53
(_dta has notes)
--------------------------------------------------------------------------
Variable Storage Display Value
name type format label Variable label
--------------------------------------------------------------------------
exp byte %9.0g Years of full-time work experience
wks byte %9.0g Weeks worked
occ byte %15.0g occ Occupation
ind byte %17.0g ind Industry
south byte %9.0g south Residence
smsa byte %9.0g smsa SMSA
ms byte %11.0g ms Marital status
fem byte %9.0g fem Female
union byte %18.0g union Wage set by union contract
ed byte %9.0g Years of education
blk byte %9.0g blk Race
lwage float %9.0g Log wage
id int %9.0g ID
t byte %9.0g Time
tdum1 byte %8.0g t== 1.0000
tdum2 byte %8.0g t== 2.0000
tdum3 byte %8.0g t== 3.0000
tdum4 byte %8.0g t== 4.0000
tdum5 byte %8.0g t== 5.0000
tdum6 byte %8.0g t== 6.0000
tdum7 byte %8.0g t== 7.0000
exp2 int %9.0g
-------------------------------------------------------------------------
我们不妨设待估模型为包含被解释变量 lwage
一阶和二阶滞后项的动态面板模型,控制变量中时变变量包含 exp、exp2、occ、ind、union (occ、ind、union 虽然是虚拟变量,但并非随时间完全不变化,故而在一阶段中作为时变变量进行估计),而我们关心的非时变变量为 ed、fem、blk。
首先进行第一阶段回归,将非时变变量全省略,仅把被解释变量 lwage 对所有时变变量回归。采用的估计方法为 Arellano/Bond 的两阶段差分 GMM (two-step difference-GMM estimator),外生变量的 IV 则为其本身,标准差则使用 Windmeijer 修正的稳健标准误。
. xtseqreg L(0/2).lwage exp exp2 occ ind union, gmmiv(L.lwage, model(difference) ///
> lagrange(1 4) collapse) iv(exp exp2 occ ind union, difference ///
> model(difference)) twostep vce(robust)
Group variable: id Number of obs = 2975
Time variable: t Number of groups = 595
Obs per group: min = 5
avg = 5
max = 5
Number of instruments = 10
(Std. err. adjusted for 595 clusters in id)
------------------------------------------------------------------------------
| WC-Robust
lwage | Coefficient std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
lwage |
L1. | 0.366 0.172 2.12 0.034 0.028 0.703
L2. | 0.101 0.073 1.38 0.168 -0.043 0.244
exp | 0.050 0.028 1.78 0.076 -0.005 0.105
exp2 | -0.000 0.000 -1.39 0.164 -0.000 0.000
occ | -0.043 0.028 -1.51 0.131 -0.098 0.013
ind | 0.048 0.031 1.58 0.115 -0.012 0.108
union | 0.007 0.029 0.24 0.808 -0.049 0.063
_cons | 2.738 1.088 2.52 0.012 0.605 4.870
------------------------------------------------------------------------------
在上述第一阶段估计完成后,残差将自动存储,作为被解释变量用于第二阶段的估计。作为一个例子,不妨假设 ed 在二阶段估计中为内生变量,我们使用 occ 作为其 IV。
. xtseqreg lwage (L(1/2).lwage exp exp2 occ ind union) ed fem blk, ///
> iv(occ fem blk, model(level)) vce(robust)
Group variable: id Number of obs = 2975
Time variable: t Number of groups = 595
------------------------------------------------------------------------------
Equation _first Equation _second
Number of obs = 2975 Number of obs = 2975
Number of groups = 595 Number of groups = 595
Obs per group: min = 5 Obs per group: min = 5
avg = 5 avg = 5
max = 5 max = 5
Number of instruments = 10 Number of instruments = 4
(Std. err. adjusted for clustering on id)
------------------------------------------------------------------------------
| Robust
lwage | Coefficient std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
_first |
lwage |
L1. | 0.366 0.172 2.12 0.034 0.028 0.703
L2. | 0.101 0.073 1.38 0.168 -0.043 0.244
exp | 0.050 0.028 1.78 0.076 -0.005 0.105
exp2 | -0.000 0.000 -1.39 0.164 -0.000 0.000
occ | -0.043 0.028 -1.51 0.131 -0.098 0.013
ind | 0.048 0.031 1.58 0.115 -0.012 0.108
union | 0.007 0.029 0.24 0.808 -0.049 0.063
_cons | 2.738 1.088 2.52 0.012 0.605 4.870
-------------+----------------------------------------------------------------
_second |
ed | 0.063 0.035 1.82 0.068 -0.005 0.132
fem | -0.097 0.058 -1.68 0.093 -0.209 0.016
blk | -0.153 0.101 -1.52 0.129 -0.351 0.045
_cons | -0.794 0.442 -1.80 0.072 -1.660 0.072
------------------------------------------------------------------------------
以上两阶段的估计流程主要是用于演示,xtseqreg
命令也可以一次性估计上述两个阶段,具体命令为:
. xtseqreg lwage (L(1/2).lwage exp exp2 occ ind union) ed fem blk, ///
> gmmiv(L.lwage, model(difference) lagrange(1 4) collapse equation(#1)) ///
> iv(exp exp2 occ ind union, difference model(difference) equation(#1)) ///
> iv(occ fem blk, model(level) equation(#2)) twostep vce(robust) both
在模型估计结束后,可以使用 estat overid
命令对两个阶段同时进行 Hansen's J-test,以检验是否存在过度识别问题。
. estat overid
Hansen's J-test for equation _first chi2(2) = 0.2935
H0: overidentifying restrictions are valid Prob > chi2 = 0.8635
Hansen's J-test for equation _second chi2(0) = 0.0000
note: coefficients are exactly identified Prob > chi2 = .
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