stata学习笔记

. ivregress gmm lw s expr tenure rns smsa (iq=med kww),igmmIteration 1: change in beta = 1.753e-05 change in W = 1.100e-02Iteration 2: change in beta = 4.872e-08 change in W = 7.880e-05Iteration 3: change in beta = 2.507e-10 change in W = 2.303e-07Instrumental variables (GMM) regression Number of obs = 758 Wald chi2(6) = 372.73 Prob > chi2 = 0.0000 R-squared = 0.2750GMM weight matrix: Robust Root MSE = .36499 Robust lw Coef. Std. Err. z P>|z| [95% Conf. Interval] iq .0140901 .0060357 2.33 0.020 .0022603 .02592 s .0603629 .0189548 3.18 0.001 .0232122 .0975135 expr .0431101 .0074113 5.82 0.000 .0285841 .057636 tenure .0299752 .0082729 3.62 0.000 .0137606 .0461898 rns -.0445114 .0344408 -1.29 0.196 -.1120142 .0229913 smsa .1267399 .0297637 4.26 0.000 .0684041 .1850757 _cons 3.207224 .3980878 8.06 0.000 2.426986 3.987462 Instrumented: iqInstruments: s expr tenure rns smsa med kww

如果希望将以上各估计值级标准误弄在同一张表中:

qui reg lw s expr tenure rns smsa,r . est sto ols_no_iq . qui reg lw iq s expr tenure rns smsa,r . est sto ols_with_iq . qui ivregress 2sls lw s expr tenure rns smsa (iq=med kww),r . est sto tsls . qui ivregress liml lw s expr tenure rns smsa (iq=med kww),r . est sto liml . qui ivregress gmm lw s expr tenure tns smsa (iq=med kww) . qui ivregress gmm lw s expr tenure rns smsa (iq=med kww) . est sto gmm . qui ivregress gmm lw s expr tenure rns smsa (iq=med kww),igmm . est sto igmm . estimates table ols_no_iq ols_with_iq tsls liml gmm igmm,b se 其中,选项b表示显示回归系数,se表示显示标准误差 Variable ols_no_iq ols_with~q tsls liml gmm igmm s .10264304 .09278735 .06078035 .06063623 .06036723 .06036285 .00620988 .00697626 .01895051 .01903397 .01895452 .01895478 expr .0381189 .03934425 .04332367 .04334159 .04311171 .04311006 .00661439 .00666033 .00741179 .0074185 .00741117 .00741133 tenure .03561456 .03420896 .02964421 .02962365 .02997643 .02997521 .00799884 .00789567 .00831697 .00832297 .00827281 .00827289 rns -.08407974 -.07453249 -.04352713 -.04338751 -.04451599 -.04451145 .02953295 .02997719 .03447789 .03452902 .03444039 .03444082 smsa .13966664 .13673691 .12722244 .1271796 .12673682 .12673991 .02805598 .02777116 .02974144 .02975994 .0297633 .02976369 iq .00327916 .01392844 .01397639 .01408883 .01409011 .00113212 .00603931 .00606812 .00603567 .00603575 _cons 4.103675 3.8951718 3.2180433 3.2149943 3.2072978 3.2072239 .08766646 .11592863 .39836829 .40014925 .39808304 .39808779 legend: b/se如果希望用一颗星表示10%显著性水平等等:

. estimates table ols_no_iq ols_with_iq tsls liml gmm igmm,star(0.1 0.05 0.01) Variable ols_no_iq ols_with_iq tsls liml gmm s .10264304*** .09278735*** .06078035*** .06063623*** .06036723*** expr .0381189*** .03934425*** .04332367*** .04334159*** .04311171*** tenure .03561456*** .03420896*** .02964421*** .02962365*** .02997643*** rns -.08407974*** -.07453249** -.04352713 -.04338751 -.04451599 smsa .13966664*** .13673691*** .12722244*** .1271796*** .12673682*** iq .00327916*** .01392844** .01397639** .01408883** _cons 4.103675*** 3.8951718*** 3.2180433*** 3.2149943*** 3.2072978*** legend: * p<.1; ** p<.05; *** p<.01 Variable igmm s .06036285*** expr .04311006*** tenure .02997521*** rns -.04451145 smsa .12673991*** iq .01409011** _cons 3.2072239*** legend: * p<.1; ** p<.05; *** p<.01

如果想像论文一样显示,则如下表:se表示在括弧中显示标准误差,p表示显示P值,r2表示显示R的平方,mtitle显示使用模型名字,

. esttab ols_no_iq ols_with_iq tsls liml gmm igmm,se r2 mtitle star > (1) (2) (3) (4) (5) (6) > ols_no_iq ols_with_iq tsls liml gmm igmm > > s 0.103*** 0.0928*** 0.0608** 0.0606** 0.0604** 0.0604*> * (0.00621) (0.00698) (0.0190) (0.0190) (0.0190) (0.0190) > expr 0.0381*** 0.0393*** 0.0433*** 0.0433*** 0.0431*** 0.0431*> ** (0.00661) (0.00666) (0.00741) (0.00742) (0.00741) (0.00741) > tenure 0.0356*** 0.0342*** 0.0296*** 0.0296*** 0.0300*** 0.0300*> ** (0.00800) (0.00790) (0.00832) (0.00832) (0.00827) (0.00827) > rns -0.0841** -0.0745* -0.0435 -0.0434 -0.0445 -0.0445 > (0.0295) (0.0300) (0.0345) (0.0345) (0.0344) (0.0344) > smsa 0.140*** 0.137*** 0.127*** 0.127*** 0.127*** 0.127*> ** (0.0281) (0.0278) (0.0297) (0.0298) (0.0298) (0.0298) > iq 0.00328** 0.0139* 0.0140* 0.0141* 0.0141*> (0.00113) (0.00604) (0.00607) (0.00604) (0.00604) > _cons 4.104*** 3.895*** 3.218*** 3.215*** 3.207*** 3.207*> ** (0.0877) (0.116) (0.398) (0.400) (0.398) (0.398) > > N 758 758 758 758 758 758 > R-sq 0.352 0.360 0.278 0.277 0.275 0.275 > > Standard errors in parentheses* p<0.05, ** p<0.01, *** p<0.001

二值选择模型

离散选择模型、定性反应模型或被解释变量取非负整数时,都不适宜使用OLS回归。 1、 二值选择模型:只有两种选择,是否。

Probit y x1 x2 x3,r (probit模型)

Logit y x1 x2 x3,or vce(cluster clustvar) (logit模型)

其中,r代表使用稳健标准误,or显示几率比而不是系数,vce表示使用以clustvar为聚类变量的聚类稳健标准误。

Stata举例:美国妇女就业与否的二值选择模型。

然后使用logit进行估计:

结果显示所有系数的联合显著性很高,继续使用稳健标准误进行logit回归:

对比以上两个表格显示标准误相差不大,因此不用担心模型设定问题。 二值选择模型中的异方差问题:hetprob y x1 x2 x3,het(varlist),如果接受原假设则为同方差。 此外,二值选择模型中一般都没有扰动项的存在。

二值选择模型中的异方差问题可以进行似然比检验(LR):hetprob y x1 x2 x3,het(varlist)(这是在异方差情况下进行Probit估计的stata命令,het(varlist)制定对扰动项方差有影响的所

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4