收藏 分享(赏)

工具变量法的Stata命令和实例.doc

上传人:精品资料 文档编号:9970728 上传时间:2019-09-23 格式:DOC 页数:12 大小:241.56KB
下载 相关 举报
工具变量法的Stata命令和实例.doc_第1页
第1页 / 共12页
工具变量法的Stata命令和实例.doc_第2页
第2页 / 共12页
工具变量法的Stata命令和实例.doc_第3页
第3页 / 共12页
工具变量法的Stata命令和实例.doc_第4页
第4页 / 共12页
工具变量法的Stata命令和实例.doc_第5页
第5页 / 共12页
点击查看更多>>
资源描述

1、. .工具变量法的 Stata 命令及实例 本实例使用数据集“grilic.dta” 。 先看一下数据集的统计特征:lw80 758 6.826555 .4099268 4.749 8.032 lw 758 5.686739 .4289494 4.605 7.051tenure80 758 7.362797 5.05024 0 22 tenure 758 1.831135 1.67363 0 10expr80 758 11.39426 4.210745 .692 22.045 expr 758 1.735429 2.105542 0 11.444 s80 758 13.70712 2.2146

2、93 9 18s 758 13.40501 2.231828 9 18 age80 758 33.01187 3.085504 28 38age 758 21.83509 2.981756 16 30 year 758 69.03166 2.631794 66 73 kww 758 36.57388 7.302247 12 56iq 758 103.8562 13.61867 54 145 med 758 10.91029 2.74112 0 18smsa80 758 .7124011 .452942 0 1 smsa 758 .7044855 .456575 0 1 mrt80 758 .8

3、984169 .3022988 0 1mrt 758 .5145119 .5001194 0 1 rns80 758 .292876 .4553825 0 1rns 758 .2691293 .4438001 0 1 Variable Obs Mean Std. Dev. Min Max. sum 考察智商与受教育年限的相关关系:s 0.5131 1.0000 iq 1.0000iq s(obs=758). corr iq s上表显示.智商(在一定程度上可以视为能力的代理变量)与受教育年限具有强烈的正相关关系(相关系数为 0.51) 。 作为一个参考系.先进行 OLS 回归.并使用稳健标准差:

4、. . _cons 4.103675 .0876665 46.81 0.000 3.931575 4.275775smsa .1396666 .028056 4.98 0.000 .0845893 .194744 rns -.0840797 .029533 -2.85 0.005 -.1420566 -.0261029tenure .0356146 .0079988 4.45 0.000 .0199118 .0513173 expr .0381189 .0066144 5.76 0.000 .025134 .0511038s .102643 .0062099 16.53 0.000 .0904

5、523 .1148338 lw Coef. Std. Err. t P|t| 95% Conf. Interval RobustRoot MSE = .34641 R-squared = 0.3521Prob F = 0.0000 F(5, 752) = 84.05Linear regression Number of obs = 758. reg lw s expr tenure rns smsa,r其中 expr, tenure, rns, smsa 均为控制变量.而我们主要感兴趣的是变量受教育年限(s) 。回归的结果显示.教育投资的年回报率为 10.26%.这个似乎太高了。可能的原因是.

6、由于遗漏变量“能力”与受教育正相关.故“能力”对工资的贡献也被纳入教育的贡献.因此高估了教育的回报率。 引入智商 iq 作为能力的代理变量.再进行 OLS 回归:. ._cons 3.895172 .1159286 33.60 0.000 3.667589 4.122754smsa .1367369 .0277712 4.92 0.000 .0822186 .1912553 rns -.0745325 .0299772 -2.49 0.013 -.1333815 -.0156834tenure .034209 .0078957 4.33 0.000 .0187088 .0497092 expr

7、 .0393443 .0066603 5.91 0.000 .0262692 .0524193iq .0032792 .0011321 2.90 0.004 .0010567 .0055016 s .0927874 .0069763 13.30 0.000 .0790921 .1064826lw Coef. Std. Err. t P|t| 95% Conf. IntervalRobust Root MSE = .34454 R-squared = 0.3600Prob F = 0.0000 F(6, 751) = 71.89Linear regression Number of obs =

8、758. reg lw s iq expr tenure rns smsa,r虽然教育的投资回报率有所下降.但是依然很高。 由于用 iq 作为能力的代理变量有测量误差.故 iq 是内生变量.考虑使用变量(med(母亲的受教育年限) 、kww(在“knowledge of the World of Work”中的成绩) 、mrt(婚姻虚拟变量.已婚=1)age(年龄) )作为 iq 的工具变量.进行 2SLS回归.并使用稳健的标准差:. .Instruments: s expr tenure rns smsa med kww mrt ageInstrumented: iq_cons 4.8378

9、75 .3799432 12.73 0.000 4.0932 5.58255smsa .149983 .0322276 4.65 0.000 .0868182 .2131479 rns -.1176984 .0359582 -3.27 0.001 -.1881751 -.0472216tenure .040564 .0095848 4.23 0.000 .0217781 .05935 expr .0338041 .0074844 4.52 0.000 .019135 .0484732s .1373477 .0174989 7.85 0.000 .1030506 .1716449 iq -.01

10、15468 .0056376 -2.05 0.041 -.0225962 -.0004974lw Coef. Std. Err. z P|z| 95% Conf. IntervalRobust Root MSE = .38336 R-squared = 0.2002Prob chi2 = 0.0000 Wald chi2(6) = 355.73Instrumental variables (2SLS) regression Number of obs = 758. ivregress 2sls lw s expr tenure rns smsa (iq=med kww mrt age),r在此

11、 2SLS 回归中.教育回报率反而上升到 13.73%.而 iq 对工资的贡献居然为负值。使用工具变量的前提是工具变量的有效性。为此.进行过度识别检验.考察是否所有的工具变量均外生.即与扰动项不相关:Score chi2(3) = 51.5449 (p = 0.0000)Test of overidentifying restrictions:. estat overid结果强烈拒绝所有工具变量均外生的原假设。 考虑仅使用变量(med, kww)作为 iq 的工具变量.再次进行2SLS 回归.同时显示第一阶段的回归结果:. .Instruments: s expr tenure rns sms

12、a med kwwInstrumented: iq_cons 3.218043 .3983683 8.08 0.000 2.437256 3.998831smsa .1272224 .0297414 4.28 0.000 .0689303 .1855146 rns -.0435271 .0344779 -1.26 0.207 -.1111026 .0240483tenure .0296442 .008317 3.56 0.000 .0133432 .0459452 expr .0433237 .0074118 5.85 0.000 .0287968 .0578505s .0607803 .01

13、89505 3.21 0.001 .023638 .0979227 iq .0139284 .0060393 2.31 0.021 .0020916 .0257653lw Coef. Std. Err. z P|z| 95% Conf. IntervalRobust Root MSE = .36436 R-squared = 0.2775Prob chi2 = 0.0000 Wald chi2(6) = 370.04Instrumental variables (2SLS) regression Number of obs = 758_cons 56.67122 3.076955 18.42

14、0.000 50.63075 62.71169kww .3081811 .0646794 4.76 0.000 .1812068 .4351553 med .3470133 .1681356 2.06 0.039 .0169409 .6770857smsa .2627416 .9465309 0.28 0.781 -1.595424 2.120907 rns -2.689831 .8921335 -3.02 0.003 -4.441207 -.938455tenure .2059531 .269562 0.76 0.445 -.3232327 .7351388 expr -.4501353 .

15、2391647 -1.88 0.060 -.9196471 .0193766s 2.467021 .2327755 10.60 0.000 2.010052 2.92399 iq Coef. Std. Err. t P|t| 95% Conf. Interval RobustRoot MSE = 11.3931 Adj R-squared = 0.3001R-squared = 0.3066 Prob F = 0.0000F( 7, 750) = 47.74 Number of obs = 758First-stage regressions. ivregress 2sls lw s expr

16、 tenure rns smsa (iq=med kww),r first上表显示.教育的回报率为 6.08%.较为合理.再次进行过度识别检验:. .Score chi2(1) = .151451 (p = 0.6972)Test of overidentifying restrictions:. estat overid接受原假设.认为(med.kww)外生.与扰动项不相关。 进一步考察有效工具变量的第二个条件.即工具变量与内生变量的相关性。从第一阶段的回归结果可以看出.工具变量对内生变量具有较好的解释力。更正式的检验如下:LIML Size of nominal 5% Wald test

17、8.68 5.33 4.42 3.922SLS Size of nominal 5% Wald test 19.93 11.59 8.75 7.25 10% 15% 20% 25%2SLS relative bias (not available)5% 10% 20% 30% Ho: Instruments are weak # of excluded instruments: 2 Critical Values # of endogenous regressors: 1Minimum eigenvalue statistic = 14.9058 iq 0.0382 0.0305Variabl

18、e Partial R-sq. Adj. Partial R-sq.Sheas Sheas Sheas partial R-squarediq 0.3066 0.3001 0.0382 13.4028 0.0000Variable R-sq. R-sq. R-sq. F(2,750) Prob FAdjusted Partial Robust First-stage regression summary statistics. estat firststage,all forcenonrobust从以上结果可以看出.虽然 Sheas partial R2 不到 0.04.但是 F 统计量为 1

19、3.4010。我们知道.虽然 2SLS 是一致的.但却是有偏的.故使用 2SLS 会带. .来“显著性水平扭曲” (size distortion).而且这种扭曲随着弱工具变量而增大。上表的最后部分显示.如果在结构方程中对内生解释变量的显著性进行“名义显著性水平” (nominal size)为 5%的沃尔德检验.加入可以接受的“真实显著性水平”(true size)不超过 15%.则可以拒绝“弱工具变量”的原假设.因为最小特征值统计量为 14.91.大于临界值 11.59。总之我们有理由认为不存在弱工具变量。但为了稳健起见.下面使用对弱工具变量更不敏感的有限信息最大似然法(LIML):Ins

20、truments: s expr tenure rns smsa med kwwInstrumented: iq_cons 3.214994 .4001492 8.03 0.000 2.430716 3.999272smsa .1271796 .0297599 4.27 0.000 .0688512 .185508 rns -.0433875 .034529 -1.26 0.209 -.1110631 .0242881tenure .0296237 .008323 3.56 0.000 .0133109 .0459364 expr .0433416 .0074185 5.84 0.000 .0

21、288016 .0578816s .0606362 .019034 3.19 0.001 .0233303 .0979421 iq .0139764 .0060681 2.30 0.021 .0020831 .0258697lw Coef. Std. Err. z P|z| 95% Conf. IntervalRobust Root MSE = .36454 R-squared = 0.2768Prob chi2 = 0.0000 Wald chi2(6) = 369.62Instrumental variables (LIML) regression Number of obs = 758.

22、 ivregress liml lw s expr tenure rns smsa (iq=med kww),r结果发现.LIML 的系数估计值与 2SLS 非常接近.这也从侧面印证了“不存在弱工具变量” 。 使用工具变量法的前提是存在内生解释变量.为此须进行豪斯曼检验.其原假设是“所有的解释变量均为外生”:. . (V_b-V_B is not positive definite) Probchi2 = 0.0499= 3.84 chi2(1) = (b-B)(V_b-V_B)(-1)(b-B)Test: Ho: difference in coefficients not systemat

23、icB = inconsistent under Ha, efficient under Ho; obtained from regress b = consistent under Ho and Ha; obtained from ivregress_cons 3.218043 3.895172 -.6771285 .3453751smsa .1272224 .1367369 -.0095145 .0048529 rns -.0435271 -.0745325 .0310054 .0158145tenure .0296442 .034209 -.0045648 .0023283 expr .

24、0433237 .0393443 .0039794 .0020297s .0607803 .0927874 -.032007 .0163254 iq .0139284 .0032792 .0106493 .0054318iv ols Difference S.E.(b) (B) (b-B) sqrt(diag(V_b-V_B) Coefficients that the coefficients are on a similar scale. for anything unexpected and possibly consider scaling your variables somay b

25、e problems computing the test. Examine the output of your estimators coefficients being tested (7); be sure this is what you expect, or thereNote: the rank of the differenced variance matrix (1) does not equal the number of. hausman iv ols, constant sigmamore. estimates store iv. qui ivregress 2sls

26、lw s expr tenure rns smsa (iq=med kww). estimates store ols. qui reg lw iq s expr tenure rns smsa上表显示.可以在 5%的显著性水平下拒绝“所有解释变量均外生的原假设”.即认为存在内生解释变量 iq。由于传统的豪斯曼检验建立在同方差的前提下.故在上述回归中均没有使用稳健标准差。 由于传统的豪斯曼检验在异方差的情形下不成立.下面使用异方差稳健的 DWH 检验:. .Wu-Hausman F(1,750) = 3.85842 (p = 0.0499) Durbin (score) chi2(1) = 3

27、.87962 (p = 0.0489)Ho: variables are exogenous Tests of endogeneity. estat endogenous据此可认为 iq 为内生解释变量。 如果存在异方差.则 GMM 比 2SLS 更有效。为此进行如下的最优GMM 估计:. Instruments: s expr tenure rns smsa med kwwInstrumented: iq_cons 3.207298 .398083 8.06 0.000 2.427069 3.987526smsa .1267368 .0297633 4.26 0.000 .0684018 .

28、1850718 rns -.044516 .0344404 -1.29 0.196 -.1120179 .0229859tenure .0299764 .0082728 3.62 0.000 .013762 .0461908 expr .0431117 .0074112 5.82 0.000 .0285861 .0576373s .0603672 .0189545 3.18 0.001 .0232171 .0975174 iq .0140888 .0060357 2.33 0.020 .0022591 .0259185lw Coef. Std. Err. z P|z| 95% Conf. In

29、tervalRobust GMM weight matrix: Robust Root MSE = .36499 R-squared = 0.2750Prob chi2 = 0.0000 Wald chi2(6) = 372.75Instrumental variables (GMM) regression Number of obs = 758. ivregress gmm lw s expr tenure rns smsa (iq=med kww) 进行过度识别检验:Hansens J chi2(1) = .151451 (p = 0.6972)Test of overidentifyin

30、g restriction:. estat overid 由于 p 值为 0.70.故认为所有的工具变量均为外生。考虑迭代GMM:. .Instruments: s expr tenure rns smsa med kwwInstrumented: iq_cons 3.207224 .3980878 8.06 0.000 2.426986 3.987462smsa .1267399 .0297637 4.26 0.000 .0684041 .1850757 rns -.0445114 .0344408 -1.29 0.196 -.1120142 .0229913tenure .0299752

31、.0082729 3.62 0.000 .0137606 .0461898 expr .0431101 .0074113 5.82 0.000 .0285841 .057636s .0603629 .0189548 3.18 0.001 .0232122 .0975135 iq .0140901 .0060357 2.33 0.020 .0022603 .02592lw Coef. Std. Err. z P|z| 95% Conf. IntervalRobust GMM weight matrix: Robust Root MSE = .36499 R-squared = 0.2750Pro

32、b chi2 = 0.0000 Wald chi2(6) = 372.73Instrumental variables (GMM) regression Number of obs = 758Iteration 3: change in beta = 2.495e-10 change in W = 2.304e-07Iteration 2: change in beta = 4.872e-08 change in W = 7.880e-05Iteration 1: change in beta = 1.753e-05 change in W = 1.100e-02. ivregress gmm

33、 lw s expr tenure rns smsa (iq=med kww),igmm 如果希望将以上各种估计法的系数估计值及其标准差列在同一张表中.可使用如下命令:. . _cons 3.2072239 iq .01409011 smsa .12673991 rns -.04451145 tenure .02997521 expr .04311006 s .06036285 Variable igmm _cons 4.103675 3.8951718 3.2180433 3.2149943 3.2072978 iq .00327916 .01392844 .01397639 .014088

34、83 smsa .13966664 .13673691 .12722244 .1271796 .12673682 rns -.08407974 -.07453249 -.04352713 -.04338751 -.04451599 tenure .03561456 .03420896 .02964421 .02962365 .02997643 expr .0381189 .03934425 .04332367 .04334159 .04311171 s .10264304 .09278735 .06078035 .06063623 .06036723 Variable ols_no_iq ol

35、s_withq tsls liml gmm . estimates table ols_no_iq ols_with_iq tsls liml gmm igmm. estimates store igmm. qui ivregress gmm lw s expr tenure rns smsa (iq=med kww),igmm. estimates store gmm. qui ivregress gmm lw s expr tenure rns smsa (iq=med kww). estimates store liml. qui ivregress liml lw s expr ten

36、ure rns smsa (iq=med kww),r. estimates store tsls. qui ivregress 2sls lw s expr tenure rns smsa (iq=med kww),r. estimates store ols_with_iq. qui reg lw s expr tenure rns smsa iq,r. estimates store ols_no_iq. qui reg lw s expr tenure rns smsa,r欢迎您的光临,Word 文档下载后可修改编辑.双击可删除页眉页脚.谢谢!希望您提出您宝贵的意见,你的意 见是我进步的动力。赠语; 1、如果我们做与不做都会有人笑,如果做不好与做得好还会有人笑,那么我们索性就做得更好,来给人笑吧! 2、现在你不玩命的学,以后命玩你。3、我不知道年少轻狂,我只知道胜者为王。 4、不要做金钱、权利的奴隶;应学会做“金钱、权利”的主人。5、什么时候离光明最近?那就是你觉得黑暗太黑的时候。6、最值得欣赏的风景,是自己奋斗的足迹。 7、压力不是有人比你努力,而是那些比你牛 几倍的人依然比你努力。. .

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报