查看原文
其他

高维/多维面板固定效应模型:reghdfe


高维/多维面板固定效应模型:reghdfe

简介

reghdfe该命令吸收了面板线性回归多层次的固定效应,可以进行高维/多维面板固定效应模型估计。

reghdfe是areg(和xtreg,fe, xtivreg,fe)的一般化,用于多水平固定效应(包括异质斜率)、备选估计量(2sls, gmm2s, liml)和附加鲁棒标准误差。

reghdfe命令可以包含多维固定效应模型,只需 absorb (var1,var2,var3,...),就可以进行多维固定效应模型估计。reghdfe是一个外部命令,所以大家在使用之前需要安装(ssc install reghdfe或者help reghdfe或者findit reghdfe进行下载)。

语法格式为:

 reghdfe depvar [indepvars] [if] [in] [weight] , absorb(absvars) [options]

选项含义为:

  • depvar 表示被解释变量

  • indepvars表示解释变量

  • absorb(absvars)表示将被吸收的固定效应,即加入个体或者时间固定效应

  • absorb(..., savefe)表示 保存所有带有__hdfe前缀的固定效果估算值

  • residuals(newvar)表示保存的残差

案例应用

1、导入数据

sysuse auto

2、进行单一维度固定效应模型估计

    Simple case - one fixed effect
        . reghdfe price weight length, absorb(rep78)

3、如上,但是加上聚类稳健标准误

        . reghdfe price weight length, absorb(rep78) vce(cluster rep78)

4、下面进行二维三维固定效应模型估计

 Two and three sets of fixed effects
 webuse nlswork

# 二维面板固定效应模型估计
reghdfe ln_w grade age ttl_exp tenure not_smsa south , absorb(idcode year)

# 三维面板固定效应模型估计
reghdfe ln_w grade age ttl_exp tenure not_smsa south , absorb(idcode year occ)

结果为:

 sysuse auto
(1978 Automobile Data)


. reghdfe price weight length, absorb(rep78)
(MWFE estimator converged in 1 iterations)

HDFE Linear regression                            Number of obs   =         69
Absorbing 1 HDFE group                            F(   2,     62) =      22.98
                                                  Prob > F        =     0.0000
                                                  R-squared       =     0.4341
                                                  Adj R-squared   =     0.3793
                                                  Within R-sq.    =     0.4258
                                                  Root MSE        =  2294.5106

------------------------------------------------------------------------------
       price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      weight |   5.478309   1.158582     4.73   0.000     3.162337    7.794281
      length |  -109.5065   39.26104    -2.79   0.007    -187.9882   -31.02482
       _cons |   10154.62   4270.525     2.38   0.021      1617.96    18691.27
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
       rep78 |         5           0           5     |
-----------------------------------------------------+

.  . reghdfe price weight length, absorb(rep78) vce(cluster rep78)
(MWFE estimator converged in 1 iterations)

HDFE Linear regression                            Number of obs   =         69
Absorbing 1 HDFE group                            F(   2,      4) =      21.65
Statistics robust to heteroskedasticity           Prob > F        =     0.0072
                                                  R-squared       =     0.4341
                                                  Adj R-squared   =     0.3793
                                                  Within R-sq.    =     0.4258
Number of clusters (rep78)   =          5         Root MSE        =  2294.5106

                                  (Std. Err. adjusted for 5 clusters in rep78)
------------------------------------------------------------------------------
             |               Robust
       price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      weight |   5.478309   .8536918     6.42   0.003     3.108081    7.848538
      length |  -109.5065   25.31469    -4.33   0.012    -179.7914   -39.22167
       _cons |   10154.62   4209.396     2.41   0.073     -1532.54    21841.77
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
       rep78 |         5           5           0    *|
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation


 use "nlswork.dta", clear
(National Longitudinal Survey of Young Women, 14-24 years old in 1968)

.  reghdfe ln_w grade age ttl_exp tenure not_smsa south , absorb(idcode year)
(dropped 550 singleton observations)
note: grade is probably collinear with the fixed effects (all partialled-out v
> alues are close to zero; tol = 1.0e-09)
(MWFE estimator converged in 8 iterations)
note: grade omitted because of collinearity

HDFE Linear regression                            Number of obs   =     27,541
Absorbing 2 HDFE groups                           F(   5,  23375) =     261.99
                                                  Prob > F        =     0.0000
                                                  R-squared       =     0.6762
                                                  Adj R-squared   =     0.6185
                                                  Within R-sq.    =     0.0531
                                                  Root MSE        =     0.2939

------------------------------------------------------------------------------
     ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       grade |          0  (omitted)
         age |   .0114497   .0099824     1.15   0.251    -.0081165    .0310159
     ttl_exp |   .0323758   .0015046    21.52   0.000     .0294266     .035325
      tenure |   .0104689   .0009264    11.30   0.000     .0086531    .0122847
    not_smsa |  -.0914148   .0096386    -9.48   0.000    -.1103071   -.0725225
       south |  -.0640471   .0110539    -5.79   0.000    -.0857134   -.0423808
       _cons |   1.161841    .290702     4.00   0.000     .5920463    1.731636
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
      idcode |      4147           0        4147     |
        year |        15           1          14     |
-----------------------------------------------------+

. reghdfe ln_w grade age ttl_exp tenure not_smsa south , absorb(idcode year occ)
(dropped 544 singleton observations)
note: grade is probably collinear with the fixed effects (all partialled-out values ar
> e close to zero; tol = 1.0e-09)
(MWFE estimator converged in 15 iterations)
note: grade omitted because of collinearity

HDFE Linear regression                            Number of obs   =     27,427
Absorbing 3 HDFE groups                           F(   5,  23255) =     243.90
                                                  Prob > F        =     0.0000
                                                  R-squared       =     0.6957
                                                  Adj R-squared   =     0.6411
                                                  Within R-sq.    =     0.0498
                                                  Root MSE        =     0.2851

------------------------------------------------------------------------------
     ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       grade |          0  (omitted)
         age |   .0072158    .009709     0.74   0.457    -.0118146    .0262461
     ttl_exp |   .0304072   .0014669    20.73   0.000      .027532    .0332824
      tenure |   .0096777    .000902    10.73   0.000     .0079098    .0114457
    not_smsa |  -.0937477   .0093765   -10.00   0.000    -.1121263   -.0753691
       south |  -.0597921   .0107538    -5.56   0.000    -.0808703   -.0387139
       _cons |   1.298791   .2827473     4.59   0.000     .7445875    1.852994
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
      idcode |      4141           0        4141     |
        year |        15           1          14     |
    occ_code |        13           1          12    ?|
-----------------------------------------------------+
? = number of redundant parameters may be higher






您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存