xtseqreg:面板模型如何估计不随时间变化的变量

发布时间:2020-10-26 阅读 10611

Stata连享会   主页 || 视频 || 推文 || 知乎

温馨提示: 定期 清理浏览器缓存,可以获得最佳浏览体验。

New! lianxh 命令发布了:
随时搜索连享会推文、Stata 资源,安装命令如下:
. ssc install lianxh
使用详情参见帮助文件 (有惊喜):
. help lianxh

课程详情 https://gitee.com/arlionn/Course   |   lianxh.cn

课程主页 https://gitee.com/arlionn/Course

作者: 展一帆 (复旦大学)
E-Mail: simonzhanyf@163.com
Stata 连享会: 知乎 | 简书 | 码云 | CSDN

Source: Estimation of linear dynamic panel data models with time-invariant regressors


目录


1. 问题背景

在常见的固定效应静态面板模型中,非时变的变量由于与个体固定效应完全共线性,无法估计出系数,在 Stata 中会直接汇报 omitted。

另一方面,在动态面板模型中,我们一般使用 GMM 估计方法。(Arellano and Bond,1991; Arellano and Bover,1995; Blundell and Bond ,1998)当 GMM 方法在不满足强正交性假设,对非时变变量的估计系数也是不一致且有偏的。

然而,在许多研究中,非时变变量在结构性方程中起着重要作用。例如在劳动经济学或卫生经济学领域中,学者时常会感兴趣一些非时变变量对于因变量(如工资水平或健康程度等)的影响,如教育、性别、国籍、种族和宗教背景等。

故而本文旨在介绍一种新的二阶段估计程序 xtseqreg,可以在不依赖正交性假设的情况下估计非时变变量的系数(Kripfganz1 and Schwarz, 2019)。

2. 估计流程与原理

xtseqreg 命令的主要目的是估计带有非时变变量的线性(动态)面板数据模型。概括而言,估计流程分为两阶段,在第一阶段只对时变变量回归估计其系数,并提取回归的残差,然后在第二阶段将该残差对非时变变量进行回归,获取非时变变量的系数。

具体而言,不妨考虑如下动态面板模型:

其中个体 i 取值为 1,2,3,...,N,时间 t 取值为 1,2,3,...,Txit 是 Kx×1 维向量,代表随时间变化的自变量, fi 是 Kf×1 维向量,代表非时变自变量。αi 代表不可观测的个体固定效应。

实现该二阶段估计方法需要满足两条假设:

  • 假设 1: 扰动项 uit 和个体效应 αi 在个体 i 之间独立分布,且对任意 st 满足 E[uit]=E[αi]=0,E[uisuit]=0 ,以及 E[αiuit]=0

  • 假设 2: 相对于扰动项 uitxit 和 fi 严格外生,即 E[uitxi0,xi1,,xiT,fi;αi]=0

在第一阶段里,我们先把非时变变量与个体固定效应合并为 ηi=fiγ+αi,则第一阶段模型可改写为如下方程:

在满足假设 1 和假设 2 的情况下,一阶段方程可使用多种常规估计方法,例如 Hsiao et al. (2002)的 QML 估计量,Arellano and Bond (1991) 和 Blundell and Bond (1998) 基于线性矩条件的 GMM 估计量,Ahn and Schmidt (1995) 基于非线性矩条件的 GMM 估计量等。

接下来将一阶段估计的残差提取出来,采用如下水平方程回归即可得到非时变变量的估计系数:

此外,上述两个阶段均可以使用工具变量解决自变量的内生性问题。在第二阶段,本方法纠正了通常的标准误,标准误修正也是这个新命令的主要贡献之一。有关该修正及其益处的详细信息,请参阅论文。

另外值得一提的是,xtseqreg 命令也可以用于常规 IV/GMM 估计单阶段。例如本命令可以模仿实现(部分)现有命令的行为,用于工具变量和线性面板数据模型的 GMM 估计,特别是动态模型环境下的 xtdpdxtabond2。但本命令并非旨在替代以往的命令,在某种程度上,其他命令包含一些本命令所不能实现的功能,但是本命令相比之下提供了额外的灵活性,且实现了两阶段估计中标准误的纠偏。

3. Stata 范例

本小节我们来看一个应用实例。详细可以参考 Sebastian Kripfganz 在 Statalist 上分享的实用案例:XTSEQREG: new Stata command for sequential / two-stage (GMM) estimation of linear panel models

3.1 xtseqreg 命令的安装

xtseqreg 命令由 Sebastian Kripfganz 博士编写,其 主页 还发布了一系列相关命令和文档。xtseqreg 的安装方式如下:

*-途径一
. ssc install xtseqreg, replace  // 安装最新版,更新较为缓慢
*-途径二:更新及时,但有时可能无法连网
. net install xtseqreg, from(http://www.kripfganz.de/stata/)

完成安装后,可以进一步输入如下命令获取帮组文件:

. help xtseqreg
. help xtseqreg postestimation

范例数据

本例中使用程序作者提供的数据文件 psidextract.dta 来演示该命令的用法。

首先可以了解一下该范例数据,期为一个劳动-收入领域的面板数据,我们关心的被解释变量是 lwage,即对数工资,idt 则分别对应面板的横截面和时间指标,此外数据中包含了大量随时间不变的变量,例如是否为黑人 blk、性别 fem 等等。通常的固定效应面板回归无法估计这些非时变变量。

. webuse psidextract.dta, clear  // Stata 手册附带数据
 des

Contains data from psidextract.dta
  obs:         4,165
 vars:            22        3 Aug 2020 23:58
 size:       279,055        (_dta has notes)
----------------------------------------------------------------------------
         storage  
variable   type     variable label
----------------------------------------------------------------------------
exp        float    years of full-time work experience
wks        float    weeks worked
occ        float    occupation; occ==1 if in a blue-collar occupation
ind        float    industry; ind==1 if working in a manufacturing industry
south      float    residence; south==1 if in the South area
smsa       float    smsa==1 if in the Standard metropolitan statistical area
ms         float    marital status
fem        float    female or male
union      float    if wage set be a union contract
ed         float    years of education
blk        float    black
lwage      float    log wage
id         float  
t          float  
tdum1      byte     t== 1.0000
tdum2      byte     t== 2.0000
tdum3      byte     t== 3.0000
tdum4      byte     t== 4.0000
tdum5      byte     t== 5.0000
tdum6      byte     t== 6.0000
tdum7      byte     t== 7.0000
exp2       float  
----------------------------------------------------------------------------
Sorted by: id  t

我们不妨设待估模型为包含被解释变量 lwage 的一阶和二阶滞后项的动态面板模型,控制变量中时变变量包含 exp, exp2, occ, ind, unionocc, ind, union 虽然是虚拟变量,但并非随时间完全不变化,故而在一阶段中作为时变变量进行估计),而我们关心的非时变变量则为 ed, femblk

首先进行第一阶段回归,将非时变变量全略去,仅把被解释变量 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)
// 估计该模型所用的命令(命令中的选项可通过help文档详细了解)

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 clustering on id)
-------------------------------------------------------------------------
        |              WC-Robust
  lwage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
--------+----------------------------------------------------------------
  lwage |
    L1. |    .365887   .1722314     2.12   0.034     .0283197    .7034543
    L2. |   .1009276   .0732219     1.38   0.168    -.0425848    .2444399
        |
    exp |   .0501576   .0282205     1.78   0.076    -.0051536    .1054688
   exp2 |   -.000206    .000148    -1.39   0.164     -.000496     .000084
    occ |  -.0428486   .0283624    -1.51   0.131    -.0984379    .0127406
    ind |   .0481791   .0305408     1.58   0.115    -.0116798     .108038
  union |    .006991   .0288093     0.24   0.808    -.0494742    .0634562
  _cons |   2.737719   1.088102     2.52   0.012     .6050775     4.87036
-------------------------------------------------------------------------

在上述第一阶段估计完成后,残差将自动存储,作为被解释变量用于第二阶段的估计。作为一个例子,不妨假设 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 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
_first       |
       lwage |
         L1. |    .365887   .1722314     2.12   0.034     .0283197    .7034543
         L2. |   .1009276   .0732219     1.38   0.168    -.0425848    .2444399
             |
         exp |   .0501576   .0282205     1.78   0.076    -.0051536    .1054688
        exp2 |   -.000206    .000148    -1.39   0.164     -.000496     .000084
         occ |  -.0428486   .0283624    -1.51   0.131    -.0984379    .0127406
         ind |   .0481791   .0305408     1.58   0.115    -.0116798     .108038
       union |    .006991   .0288093     0.24   0.808    -.0494742    .0634562
       _cons |   2.737719   1.088102     2.52   0.012     .6050775     4.87036
-------------+----------------------------------------------------------------
_second      |
          ed |   .0634885   .0348497     1.82   0.068    -.0048158    .1317927
         fem |  -.0967082   .0575629    -1.68   0.093    -.2095295     .016113
         blk |  -.1531252   .1010073    -1.52   0.130     -.351096    .0448456
       _cons |  -.7936727   .4419754    -1.80   0.073    -1.659929    .0725831
------------------------------------------------------------------------------

以上两阶段的估计流程主要是用于演示,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,检验是否存在过度识别问题。(在本例子中,第二阶段是恰好识别(exactly identified))

. 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 =         .

另外也可以使用 estat serial 实现 Arellano-Bond 的序列相关性检验。

. estat serial, ar(1/3)

Arellano-Bond test for autocorrelation of the first-differenced residuals
H0: no autocorrelation of order 1:  z = -3.3576   Prob > |z| = 0.0008
H0: no autocorrelation of order 2:  z = -0.4852   Prob > |z| = 0.6275
H0: no autocorrelation of order 3:  z =  0.2946   Prob > |z| = 0.7683

最后值得一提的是,xtseqreg 命令有很强的灵活性,可以实现大多数以往命令的效果,例如可以使用 xtabond2 实现与上述第一阶段完全一致的结果:

. xtabond2 L(0/2).lwage exp exp2 occ ind union,  ///
      gmmstyle(L.lwage, equation(diff) laglimits(1 4) collapse) ///
      ivstyle(exp exp2 occ ind union, equation(diff)) ///
      twostep robust

4. 参考资料和扩展阅读

  1. XTSEQREG: new Stata command for sequential / two-stage (GMM) estimation of linear panel models. -Link-
  2. Kripfganz S, Schwarz C. Estimation of linear dynamic panel data models with time‐invariant regressors[J]. Journal of Applied Econometrics, 2019, 34(4): 526-546. Data set and Stata replication file, Online appendix, Discussion at Statalist, -Link-, -PDF-
  3. Breitung, J., K. Hayakawa, and S. Kripfganz (2019). Asymptotically efficient method of moments estimators for dynamic panel data models. Working Paper, University of Cologne. -PDF-

相关课程

连享会-直播课 上线了!
http://lianxh.duanshu.com

免费公开课:


课程一览

支持回看

专题 嘉宾 直播/回看视频
最新专题 因果推断, 空间计量,寒暑假班等
数据清洗系列 游万海 直播, 88 元,已上线
研究设计 连玉君 我的特斯拉-实证研究设计-幻灯片-
面板模型 连玉君 动态面板模型-幻灯片-
面板模型 连玉君 直击面板数据模型 [免费公开课,2小时]

Note: 部分课程的资料,PPT 等可以前往 连享会-直播课 主页查看,下载。


关于我们

  • Stata连享会 由中山大学连玉君老师团队创办,定期分享实证分析经验。直播间 有很多视频课程,可以随时观看。
  • 连享会-主页知乎专栏,300+ 推文,实证分析不再抓狂。
  • 公众号关键词搜索/回复 功能已经上线。大家可以在公众号左下角点击键盘图标,输入简要关键词,以便快速呈现历史推文,获取工具软件和数据下载。常见关键词:课程, 直播, 视频, 客服, 模型设定, 研究设计, stata, plus, 绘图, 编程, 面板, 论文重现, 可视化, RDD, DID, PSM, 合成控制法

连享会主页  lianxh.cn
连享会主页 lianxh.cn

连享会小程序:扫一扫,看推文,看视频……

扫码加入连享会微信群,提问交流更方便

✏ 连享会学习群-常见问题解答汇总:
https://gitee.com/arlionn/WD

New! lianxh 命令发布了:
随时搜索连享会推文、Stata 资源,安装命令如下:
. ssc install lianxh
使用详情参见帮助文件 (有惊喜):
. help lianxh