Stata:支持加入多维固定效应的中介效应命令-medhdfe

发布日期:2024-08-22 11:27    点击次数:98
1 medhdfe简介

运用Stata进行中介效应分析时,你是否曾经为如何加入时间固定效应和个体固定效应而烦恼呢?

全新编写的Stata命令medhdfe重磅首发,支持在进行中介效应分析时控制多维固定效应,让你和烦恼说拜拜。

2 medhdfe特点

medhdfe将中介效应命令sgmediation2与多维固定效应命令reghdfe相结合,完美解决在中介效应分析时如何加入多维固定效应的问题。

相比在sgmediation2命令中的控制变量部分引入多个维度虚拟变量,medhdfe通过absorb加入多维固定效应,极大提高了运行速度。

medhdfe还支持加入稳健标准误,包括异方差稳健标准误robust和聚类稳健标准误cluster。

3 medhdfe语法medhdfe depvar [if exp] [in range] , iv(indepvar) mv(medvar) cv(ctrlvar) absorb(absvars) [options]

其中,depvar为因变量,indepvar为自变量,medvar为中介变量,ctrlvar为控制变量,absvars为固定维度。

4 medhdfe示例

以grunfeld.dta数据集为例,对medhdfe命令的运用进行演示。

示例以invest为因变量,mvalue为自变量,kstock为中介变量,同时控制company公司固定效应和year年份固定效应。

webuse 'grunfeld', clearmedhdfe invest, iv(mvalue) mv(kstock) absorb(company year)

具体结果如下:

Model with dv regressed on iv (path c) reghdfe invest mvalue , absorb(company year) cluster() vce()(MWFE estimator converged in 2 iterations)HDFE Linear regression Number of obs = 200Absorbing 2 HDFE groups F( 1, 170) = 76.08 Prob > F = 0.0000 R-squared = 0.8808 Adj R-squared = 0.8604 Within R-sq. = 0.3092 Root MSE = 81.0287------------------------------------------------------------------------------ invest | Coefficient Std. err. t P>|t| [95% conf. interval]-------------+---------------------------------------------------------------- mvalue | .1799679 .0206334 8.72 0.000 .1392372 .2206986 _cons | -48.70963 23.0425 -2.11 0.036 -94.19591 -3.223356------------------------------------------------------------------------------Absorbed degrees of freedom:-----------------------------------------------------+ Absorbed FE | Categories - Redundant = Num. Coefs |-------------+---------------------------------------| company | 10 0 10 | year | 20 1 19 |-----------------------------------------------------+Model with mediator regressed on iv (path a) reghdfe kstock mvalue , absorb(company year) cluster() vce()(MWFE estimator converged in 2 iterations)HDFE Linear regression Number of obs = 200Absorbing 2 HDFE groups F( 1, 170) = 15.30 Prob > F = 0.0001 R-squared = 0.7127 Adj R-squared = 0.6637 Within R-sq. = 0.0826 Root MSE = 174.6154------------------------------------------------------------------------------ kstock | Coefficient Std. err. t P>|t| [95% conf. interval]-------------+---------------------------------------------------------------- mvalue | .1739291 .0444647 3.91 0.000 .0861551 .2617031 _cons | 87.88131 49.65618 1.77 0.079 -10.14081 185.9034------------------------------------------------------------------------------Absorbed degrees of freedom:-----------------------------------------------------+ Absorbed FE | Categories - Redundant = Num. Coefs |-------------+---------------------------------------| company | 10 0 10 | year | 20 1 19 |-----------------------------------------------------+Model with dv regressed on mediator and iv (paths b and c') reghdfe invest kstock mvalue , absorb(company year) cluster() vce()(MWFE estimator converged in 2 iterations)HDFE Linear regression Number of obs = 200Absorbing 2 HDFE groups F( 2, 169) = 217.44 Prob > F = 0.0000 R-squared = 0.9517 Adj R-squared = 0.9431 Within R-sq. = 0.7201 Root MSE = 51.7245------------------------------------------------------------------------------ invest | Coefficient Std. err. t P>|t| [95% conf. interval]-------------+---------------------------------------------------------------- kstock | .3579163 .022719 15.75 0.000 .3130667 .4027659 mvalue | .1177158 .0137513 8.56 0.000 .0905694 .1448623 _cons | -80.16378 14.84402 -5.40 0.000 -109.4674 -50.86019------------------------------------------------------------------------------Absorbed degrees of freedom:-----------------------------------------------------+ Absorbed FE | Categories - Redundant = Num. Coefs |-------------+---------------------------------------| company | 10 0 10 | year | 20 1 19 |-----------------------------------------------------+Sobel-Goodman Mediation Tests | Est Std_err z P>|z| ---------------------+------------------------------------------------ Sobel | 0.062 0.016 3.796 0.000 Aroian | 0.062 0.016 3.789 0.000 Goodman | 0.062 0.016 3.804 0.000 Indirect, Direct, and Total Effects | Est Std_err z P>|z| ---------------------+------------------------------------------------ a_coefficient | 0.174 0.044 3.912 0.000 b_coefficient | 0.358 0.023 15.754 0.000 Indirect_effect_aXb | 0.062 0.016 3.796 0.000 Direct_effect_c' | 0.118 0.014 8.560 0.000 Total_effect_c | 0.180 0.021 8.722 0.000 Proportion of total effect that is mediated: 0.346Ratio of indirect to direct effect: 0.529Ratio of total to direct effect: 1.5295 medhdfe获取 本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报。