温馨提示: 定期 清理浏览器缓存,可以获得最佳浏览体验。
作者:王乔 (中南财经政法大学)
目录
广义矩估计 ( Generalized Method of Moment , 简称 GMM ) 是一种构造估计量的方法,类似于极大似然法 ( MLE ) 。 MLE 通过假设随机变量服从特定的分布,进而将待估参数嵌入似然函数,通过极大化联合概率密度函数得到参数的估计值。 GMM 则是以随机变量遵循特定矩的假设,而不是对整个分布的假设,这些假设被称为矩条件。这使得 GMM 比 MLE 更稳健,但会导致估计量的有效性有所降低 (估计出的标准误比较大)。
其中,
我们想要估计随机变量
其中,
因此,我们可知母体矩条件的样本均值估计为:
例子:
自由度为
这个母体中随机抽取的一组样本观察值
矩估计法是用样本的
一般地,不论总体服从什么分布,总体期望
OLS 估计可以视为矩估计的一个特例。OLS 估计的公式为:
其中,
其中,
求解即可得到 OLS 估计下的
工具变量法(IV)是为了解决一个违反经典假设问题而设计的,假设条件是:解释变量与随机扰动项不相关。如果出现了违反该假设的问题,就需要找一个和解释变量高度相关的、同时和随机扰动项不相关的变量。
要注意的问题是,工具变量的设定除了上述两个条件以外,工具变量的个数至少要大于或者等于解释变量的个数,常数项是默认的工具变量,和随机扰动项不相关的解释变量也可以作为工具变量。工具变量是矩估计的一种形式。
假设公式为:
其中,
求解即可得到工具变量估计下的
连享会计量方法专题……
在 GMM 估计中,假设待估参数的个数为
GMM 是矩估计(MM)的推广。在恰好识别情况下,目标函数的最小值等于 0,GMM 估计量与 MM 估计量等价;然而在过度识别情况下,MM 不再适用,GMM 可以有效地组合矩条件,使 GMM 比 MM 更有效。
在 GMM 估计中,
母体矩条件为:
样本矩条件为:
通过求解样本矩条件得到
GMM 均值估计:
。
两阶段最小二乘法其本质上是属于工具变量,回归分两个阶段进行,因此而得名。具体机理是:
第一步,将结构方程先转换为简化式模型(约简型方程),简化式模型里的每一个方程都不存在随机解释变量问题,可以直接采用普通最小二乘法进行估计。
第二步,由第一步得出的
例子: 一般 IV 回归模型为:
其中:
以单内生回归变量的 2SLS 为例,当只有一个内生回归变量
其中同前
2SLS 的总体第一阶段回归将
其中
在 2SLS 的第一阶段中,可用 OLS 估计( c )式中的未知系数,并记由该回归得到的预测值为
在 2SLS 的第二阶段中,用 OLS 估计
当存在多个内生回归变量
在 2SLS 的第二阶段中,用 OLS 估计内生回归变量(
上面提到了,只有恰好识别和过度识别才能用 IV 方法估计。假设待估参数的个数为
一个很重要的命题是:只有过度识别情况下才能检验工具变量的外生性,而恰好识别情况下无法检验。
具体思路如下:工具变量的外生性意味着它们和
为基于所有工具变量的 2SLS 回归估计残差(由于抽样变异性因此是近似的而不是精确地,注意到这些残差是利用
于是,如果工具变量事实上是外生的,那么
过度识别约束检验( J 统计量),又称为 Sargan 统计量。令
利用 OLS 估计下面的回归系数:
其中
在 Hansen、Singleton (1982)的经典文章中,他们基于消费的资产资本定价模型分析了资产随时间的移动。
在他们的非线性理性预期模型的一个稍微简单的版本中,代表性最大化的期望贴现寿命效用为:
其中受到的预算约束为:
Hansen 和 Singleton 使用一个恒定的相对风险厌恶效用函数
但是,对任意向量
因此,从理论上讲,该模型是通过时刻t已知的任何代理变量来识别的,比如
连享会计量方法专题……
在 Stata 中, gmm 的一般命令形式为:
gmm ([reqname1:]rexp_1) ([reqname2:]rexp_2) . . . [if] [in] [weight] [,options]
其中:
reqname_j
代表第 j 个剩余方程的表达式rexp_j
是第 j 个残差方程的可替换表达式GMM 的矩估计命令形式为:
gmm moment_pro [if] [in] [weight],
{equations(namelist) | nequations(#)}
{parameters(namelist) | nparameters(#)} [options]
[program_options]
其中,moment_prog
是以矩条件为基础构造的矩估计表达式。
各个选项具体说明如下:
derivative([reqname|#]/name=dexp_jk)
:指定 reqname (或 # )
对参数名的导数;可指定多于一次。twostep
:使用两步 GMM 估计onestep
:使用一步 GMM 估计igmm
:使用迭代 GMM 估计variables ( varlist )
:在模型中指定变量nocommonesample
:不要限制所有方程的估计样本都是相同的instruments([reqlist:]varlist)[,noconstant])
: 是制定工具;可以被多次指定xtinstruments([reqlist:]varlist,lags(#_1/#_2))
:是制定面板类工具变量;可以被多次指定wmatrix(wmtype[,independent])
:指定权重矩阵; wmtype
可以是robust
,cluster
clustvar
, hac kernel [lags]
,或者 unadjusted
center
: 计算权重矩阵时的中心矩winitial(iwtype[, independent])
: 指定初始权重矩阵; iwtype
可以是unadjested
, identity
, xt xtspec
,或者 Stata 矩阵的名字vce(vcetype[,independent])
: 其中 vcetype
可以是 robust
, cluster
clustvar
, bootstrap
, jackknife
, hac kernel lags
,或者 unadjusted
quickderivatives
:采用VCE数值导数的另一种计算方法level(#)
:设置置信水平;默认是水平( 95 )title(string)
:将字符串显示为参数估计表上方的标题title2(string)
:显示字符串作为副标题display_options
:控制列与列格式、行间距、行宽、显示省略的变量、基单元格与空单元格,以及因子-变量标记from(initial_values)
:参数的指定初始值igmmiterate(#)
:指定迭代 GMM 估计的最大迭代次数igmmeps
:迭代的 GMM 参数收敛准则指定为 # ;默认为 igmmeps(1e-6)igmmweps( # )
:迭代的 GMM 权重矩阵收敛准则指定为 # ;默认是 igmmweps (1e-6)optimization_options
:控制优化过程;很少使用coeflegend
:显示图例而不是统计数据在对 gmm 命令的一般形式有了解之后,此处举个简单的案例来进行 gmm 的分析。以 Stata 自带的数据 auto.dta 为例,进行以下的 GMM 实验:
Stata 操作为:
sysuse auto,clear
regress mpg gear_ratio turn
gmm (mpg - {b1}*gear_ratio - {b2}*turn - {b0}),instruments(gear_ratio turn)
结果如下:
. gmm (mpg - {b1}*gear_ratio - {b2}*turn - {b0}),instruments(gear_ratio turn)
Step 1
Iteration 0: GMM criterion Q(b) = 471.67875
Iteration 1: GMM criterion Q(b) = 3.058e-21
Iteration 2: GMM criterion Q(b) = 2.545e-31
Step 2
Iteration 0: GMM criterion Q(b) = 1.691e-32
Iteration 1: GMM criterion Q(b) = 1.691e-32 (backed up)
note: model is exactly identified
GMM estimation
Number of parameters = 3
Number of moments = 3
Initial weight matrix: Unadjusted Number of obs = 74
GMM weight matrix: Robust
------------------------------------------------------------------------------
| Robust
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
/b1 | 3.033 1.502 2.02 0.043 0.090 5.976
/b2 | -0.733 0.118 -6.21 0.000 -0.964 -0.502
/b0 | 41.218 8.397 4.91 0.000 24.761 57.675
------------------------------------------------------------------------------
Instruments for equation 1: gear_ratio turn _cons
Stata 操作为:
gmm (mpg - {xb:gear_ratio turn} - {b0}), instruments(gear_ratio turn)
结果如下:
Step 1
Iteration 0: GMM criterion Q(b) = 471.67875
Iteration 1: GMM criterion Q(b) = 3.058e-21
Iteration 2: GMM criterion Q(b) = 4.073e-31
Step 2
Iteration 0: GMM criterion Q(b) = 3.566e-32
Iteration 1: GMM criterion Q(b) = 3.566e-32 (backed up)
note: model is exactly identified
GMM estimation
Number of parameters = 3
Number of moments = 3
Initial weight matrix: Unadjusted Number of obs = 74
GMM weight matrix: Robust
------------------------------------------------------------------------------
| Robust
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
gear_ratio | 3.032884 1.501664 2.02 0.043 .0896757 5.976092
turn | -.7330502 .117972 -6.21 0.000 -.9642711 -.5018293
-------------+----------------------------------------------------------------
/b0 | 41.21801 8.396739 4.91 0.000 24.76071 57.67532
------------------------------------------------------------------------------
Instruments for equation 1: gear_ratio turn _cons
最小二乘法的 Stata 操作为:
ivregress 2sls mpg gear_ratio (turn = weight length headroom)
结果为:
Instrumental variables (2SLS) regression Number of obs = 74
Wald chi2(2) = 90.94
Prob > chi2 = 0.0000
R-squared = 0.4656
Root MSE = 4.2007
------------------------------------------------------------------------------
mpg | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
turn | -1.246426 .2012157 -6.19 0.000 -1.640801 -.8520502
gear_ratio | -.3146499 1.697806 -0.19 0.853 -3.642288 3.012988
_cons | 71.66502 12.3775 5.79 0.000 47.40556 95.92447
------------------------------------------------------------------------------
Instrumented: turn
Instruments: gear_ratio weight length headroom
相应 GMM 的 Stata 操作为:
gmm (mpg - {b1}*turn - {b2}*gear_ratio - {b0}), instruments(gear_ratio weight length headroom) onestep
结果如下:
Step 1
Iteration 0: GMM criterion Q(b) = 475.42283
Iteration 1: GMM criterion Q(b) = .16100633
Iteration 2: GMM criterion Q(b) = .16100633
GMM estimation
Number of parameters = 3
Number of moments = 5
Initial weight matrix: Unadjusted Number of obs = 74
------------------------------------------------------------------------------
| Robust
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
/b1 | -1.246426 .1970566 -6.33 0.000 -1.632649 -.8602019
/b2 | -.3146499 1.863079 -0.17 0.866 -3.966217 3.336917
/b0 | 71.66502 12.68722 5.65 0.000 46.79853 96.53151
------------------------------------------------------------------------------
Instruments for equation 1: gear_ratio weight length headroom _cons
我们可以使用以下两种语句进行两步 GMM 估计:
ivregress gmm mpg gear_ratio (turn = weight length headroom)
gmm (mpg - {b1}*turn - {b2}*gear_ratio - {b0}), ///
instruments(gear_ratio weight length headroom) wmatrix(robust)
第一条语句的结果为:
Instrumental variables (GMM) regression Number of obs = 74
Wald chi2(2) = 97.83
Prob > chi2 = 0.0000
R-squared = 0.4769
GMM weight matrix: Robust Root MSE = 4.1559
------------------------------------------------------------------------------
| Robust
mpg | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
turn | -1.208549 .1882903 -6.42 0.000 -1.577591 -.8395071
gear_ratio | .130328 1.75499 0.07 0.941 -3.30939 3.570046
_cons | 68.89218 12.05955 5.71 0.000 45.25589 92.52847
------------------------------------------------------------------------------
Instrumented: turn
Instruments: gear_ratio weight length headroom
第二条语句的结果为:
Step 1
Iteration 0: GMM criterion Q(b) = 475.42283
Iteration 1: GMM criterion Q(b) = .16100633
Iteration 2: GMM criterion Q(b) = .16100633
Step 2
Iteration 0: GMM criterion Q(b) = .00863899
Iteration 1: GMM criterion Q(b) = .00741189
Iteration 2: GMM criterion Q(b) = .00741189
GMM estimation
Number of parameters = 3
Number of moments = 5
Initial weight matrix: Unadjusted Number of obs = 74
GMM weight matrix: Robust
------------------------------------------------------------------------------
| Robust
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
/b1 | -1.208549 .1882903 -6.42 0.000 -1.577591 -.8395071
/b2 | .130328 1.75499 0.07 0.941 -3.30939 3.570046
/b0 | 68.89218 12.05955 5.71 0.000 45.25589 92.52847
------------------------------------------------------------------------------
Instruments for equation 1: gear_ratio weight length headroom _cons
当然 GMM 更有名的应用是在动态面板的估计上,我们可以使用 xtabond 估计动态面板。以 Stata 自带的数据 abdate.dta 为例,进行实验:
webuse abdata,clear`
`xtabond n L(0/1).w L(0/1).k, lags(1) noconstant vce(robust)
结果如下:
Arellano-Bond dynamic panel-data estimation Number of obs = 751
Group variable: id Number of groups = 140
Time variable: year
Obs per group:
min = 5
avg = 5.364286
max = 7
Number of instruments = 32 Wald chi2(5) = 658.83
Prob > chi2 = 0.0000
One-step results
(Std. Err. adjusted for clustering on id)
------------------------------------------------------------------------------
| Robust
n | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
n |
L1. | .8041712 .1199819 6.70 0.000 .5690111 1.039331
|
w |
--. | -.5600476 .1619472 -3.46 0.001 -.8774583 -.242637
L1. | .3946699 .1092229 3.61 0.000 .1805969 .6087429
|
k |
--. | .3520286 .0536546 6.56 0.000 .2468676 .4571897
L1. | -.2160435 .0679689 -3.18 0.001 -.3492601 -.0828269
------------------------------------------------------------------------------
Instruments for differenced equation
GMM-type: L(2/.).n
Standard: D.w LD.w D.k LD.k
也可以用 GMM 的形式估计动态面板,表示为:
gmm (D.n - {rho}*LD.n - {xb:D.w LD.w D.k LD.k}), ///
xtinstruments(n, lags(2/.)) ///
instruments(D.w LD.w D.k LD.k, noconstant) ///
deriv(/rho = -1*LD.n) deriv(/xb = -1) winitial(xt D) onestep
结果如下:
Step 1
Iteration 0: GMM criterion Q(b) = .0011455
Iteration 1: GMM criterion Q(b) = .00009103
Iteration 2: GMM criterion Q(b) = .00009103
GMM estimation
Number of parameters = 5
Number of moments = 32
Initial weight matrix: XT D Number of obs = 751
(Std. Err. adjusted for 140 clusters in id)
------------------------------------------------------------------------------
| Robust
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
rho |
_cons | .8041712 .1199819 6.70 0.000 .5690111 1.039331
-------------+----------------------------------------------------------------
xb |
w |
D1. | -.5600476 .1619472 -3.46 0.001 -.8774583 -.242637
LD. | .3946699 .1092229 3.61 0.000 .1805969 .6087429
|
k |
D1. | .3520286 .0536546 6.56 0.000 .2468676 .4571897
LD. | -.2160435 .0679689 -3.18 0.001 -.3492601 -.0828269
------------------------------------------------------------------------------
Instruments for equation 1:
XT-style: L(2/.).n
Standard: D.w LD.w D.k LD.k
连享会计量方法专题……
在计量经济学方法研究以及应用中,一般需要恰好识别或者过度识别,虽然过度识别的情况比较多一些,另外这是进行工具变量法的必要条件;若是出现过度识别,则需要进行过度识别检验,也称为 Sargen - Baseman 检验。
该假设的条件为所有有效的工具变量的个数与内生解释变量一样多,或者说是这个所有的工具变量都是外生的。
GMM 中过度识别的命令为 estat overid
。
若是 Sargen - Baseman 检验的统计量对应的 p 值大于 0.05,则认为所有的工具变量都是外生的,也就是有效的,反之则是无效的。(原假设是所有工具变量是外省的,若是 p 值小于 0.05,则拒绝原假设)
此处用 Stata 自带数据 auto.dta 来进行试验:
sysuse auto,clear
ivregress gmm mpg gear_ratio (turn = weight length headroom),wmatrix(robust) small
estat overid
结果如下:
Instrumental variables (GMM) regression Number of obs = 74
F( 2, 71) = 46.93
Prob > F = 0.0000
R-squared = 0.4769
Adj R-squared = 0.4622
GMM weight matrix: Robust Root MSE = 4.2428
------------------------------------------------------------------------------
| Robust
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
turn | -1.208549 .1922271 -6.29 0.000 -1.591839 -.8252594
gear_ratio | .130328 1.791684 0.07 0.942 -3.442189 3.702845
_cons | 68.89218 12.3117 5.60 0.000 44.34336 93.44101
------------------------------------------------------------------------------
Instrumented: turn
Instruments: gear_ratio weight length headroom
过度识别检验( Sargen - Baseman 检验)的结果为:
Test of overidentifying restriction:
Hansen's J chi2(2) = .54848 (p = 0.7601)
根据结果可知, Sargen - Baseman 检验统计量对应的 p 值大于 0.05,所有的工具变量都是外生有效的。
连享会-直播课 上线了!
http://lianxh.duanshu.com
免费公开课:
直击面板数据模型 - 连玉君,时长:1小时40分钟 Stata 33 讲 - 连玉君, 每讲 15 分钟. 部分直播课 课程资料下载 (PPT,dofiles等)
支持回看,所有课程可以随时购买观看。
专题 | 嘉宾 | 直播/回看视频 |
---|---|---|
⭐ 最新专题 ⭐ | DSGE, 因果推断, 空间计量等 | |
⭕ Stata数据清洗 | 游万海 | 直播, 2 小时,已上线 |
研究设计 | 连玉君 | 我的特斯拉-实证研究设计,-幻灯片- |
面板模型 | 连玉君 | 动态面板模型,-幻灯片- |
面板模型 | 连玉君 | 直击面板数据模型 [免费公开课,2小时] |
Note: 部分课程的资料,PPT 等可以前往 连享会-直播课 主页查看,下载。
关于我们
课程, 直播, 视频, 客服, 模型设定, 研究设计, stata, plus, 绘图, 编程, 面板, 论文重现, 可视化, RDD, DID, PSM, 合成控制法
等
连享会小程序:扫一扫,看推文,看视频……
扫码加入连享会微信群,提问交流更方便
✏ 连享会学习群-常见问题解答汇总:
✨ https://gitee.com/arlionn/WD