-------------
      name:  <unnamed>
       log:  E:\【计量经济学及stata】\陈强计量经济学及stata应用(网课+PPT+Data)\《计量经济学及Stata应用》Data-Finished-本科计量\第10章.smcl
  log type:  smcl
 opened on:  22 Jan 2024, 00:19:02

. use "grilic.dta",clear

.
. reg lnw s expr tenure rns smsa,r

Linear regression                               Number of obs     =        758
                                                F(5, 752)         =      84.05
                                                Prob > F          =     0.0000
                                                R-squared         =     0.3521
                                                Root MSE          =     .34641

-------------+----------------------------------------------------------------
             |               Robust
          lnw | Coefficient   std. err.       t    P>|t|      [95% con f. interval]
-------------+----------------------------------------------------------------
           s |     .102643    .0062099     16.53    0.000      .0904523     .1148338
        expr |    .0381189    .0066144      5.76    0.000       .025134     .0511038
      tenure |    .0356146    .0079988      4.45    0.000      .0199118     .0513173
         rns |   -.0840797     .029533     -2.85    0.005     -.1420566    -.0261029
        smsa |    .1396666     .028056      4.98    0.000      .0845893      .194744
       _cons |    4.103675    .0876665     46.81    0.000      3.931575     4.275775
-------------+----------------------------------------------------------------

.
. reg lnw s iq expr tenure rns smsa,r

Linear regression                               Number of obs     =        758
                                                F(6, 751)         =      71.89
                                                Prob > F          =     0.0000
                                                R-squared         =     0.3600
                                                Root MSE          =     .34454

-------------+----------------------------------------------------------------
             |               Robust
          lnw | Coefficient   std. err.       t    P>|t|      [95% con f. interval]
-------------+----------------------------------------------------------------
           s |    .0927874    .0069763     13.30    0.000      .0790921     .1064826
          iq |    .0032792    .0011321      2.90    0.004      .0010567     .0055016
        expr |    .0393443    .0066603      5.91    0.000      .0262692     .0524193
      tenure |     .034209    .0078957      4.33    0.000      .0187088     .0497092
         rns |   -.0745325    .0299772     -2.49    0.013     -.1333815    -.0156834
        smsa |    .1367369    .0277712      4.92    0.000      .0822186     .1912553
       _cons |    3.895172    .1159286     33.60    0.000      3.667589     4.122754
-------------+----------------------------------------------------------------

.
. ivregress 2sls lnw s expr tenure rns smsa (iq = med kww),r first

First-stage regressions
-----------------------

                                                       Number of obs    = 758
                                                       F(7, 750)     = 47.74
                                                       Prob > F      = 0.0000
                                                       R-squared     = 0.3066
                                                       Adj R-squared    = 0.3001
                                                       Root MSE      = 11.3931

-------------+----------------------------------------------------------------
             |               Robust
           iq | Coefficient   std. err.       t    P>|t|      [95% con f. interval]
-------------+----------------------------------------------------------------
           s |    2.467021    .2327755     10.60    0.000      2.010052      2.92399
        expr |   -.4501353    .2391647     -1.88    0.060     -.9196471     .0193766
      tenure |    .2059531     .269562      0.76    0.445     -.3232327     .7351388
         rns |   -2.689831    .8921335     -3.02    0.003     -4.441207     -.938455
        smsa |    .2627416    .9465309      0.28    0.781     -1.595424     2.120907
         med |    .3470133    .1681356      2.06    0.039      .0169409     .6770857
         kww |    .3081811    .0646794      4.76    0.000      .1812068     .4351553
       _cons |    56.67122    3.076955     18.42    0.000      50.63075     62.71169
-------------+----------------------------------------------------------------


 Instrumental variables 2SLS regression           Number of obs   =        758
                                                  Wald chi2(6)    =     370.04
                                                  Prob > chi2     =     0.0000
                                                  R-squared       =     0.2775
                                                  Root MSE        =     .36436

-------------+----------------------------------------------------------------
             |               Robust
          lnw | Coefficient   std. err.       z    P>|z|      [95% con f. interval]
-------------+----------------------------------------------------------------
          iq |    .0139284    .0060393      2.31    0.021      .0020916     .0257653
           s |    .0607803    .0189505      3.21    0.001       .023638     .0979227
        expr |    .0433237    .0074118      5.85    0.000      .0287968     .0578505
      tenure |    .0296442     .008317      3.56    0.000      .0133432     .0459452
         rns |   -.0435271    .0344779     -1.26    0.207     -.1111026     .0240483
        smsa |    .1272224    .0297414      4.28    0.000      .0689303     .1855146
       _cons |    3.218043    .3983683      8.08    0.000      2.437256     3.998831
-------------+----------------------------------------------------------------


Endogenous: iq


Exogenous:  s expr tenure rns smsa med kww


.
. estat overid

  Test of overidentifying restrictions:

  Score chi2(1)          =  .151451  (p = 0.6972)

.
. quietly ivregress 2sls lnw s expr tenure rns smsa (iq=med kww)

.
. estat firststage

  First-stage regression summary statistics
  -------------+------------------------------------------------------------
               |            Adjusted      Partial
      Variable |   R-sq.       R-sq.        R-sq.      F(2,750)   Prob > F
  -------------+------------------------------------------------------------
            iq |  0.3066      0.3001       0.0382       14.9058    0.0000
  -------------+------------------------------------------------------------


  Minimum eigenvalue statistic = 14.9058

  Critical Values                      # of endogenous regressors:    1
  H0: Instruments are weak             # of excluded instruments:     2
  -----------------------------------+---------------------------------
                                     |    5%     10%     20%     30%
  2SLS relative bias                 |         (not available)
  -----------------------------------+---------------------------------
                                     |   10%     15%     20%     25%
  2SLS size of nominal 5% Wald test  |  19.93   11.59    8.75    7.25
  LIML size of nominal 5% Wald test  |   8.68    5.33    4.42    3.92
  -----------------------------------+---------------------------------


.
. ivregress liml lnw s expr tenure rns smsa (iq = med kww),r

 Instrumental variables LIML regression           Number of obs   =        758
                                                  Wald chi2(6)    =     369.62
                                                  Prob > chi2     =     0.0000
                                                  R-squared       =     0.2768
                                                  Root MSE        =     .36454

-------------+----------------------------------------------------------------
             |               Robust
          lnw | Coefficient   std. err.       z    P>|z|      [95% con f. interval]
-------------+----------------------------------------------------------------
          iq |    .0139764    .0060681      2.30    0.021      .0020831     .0258697
           s |    .0606362     .019034      3.19    0.001      .0233303     .0979421
        expr |    .0433416    .0074185      5.84    0.000      .0288016     .0578816
      tenure |    .0296237     .008323      3.56    0.000      .0133109     .0459364
         rns |   -.0433875     .034529     -1.26    0.209     -.1110631     .0242881
        smsa |    .1271796    .0297599      4.27    0.000      .0688512      .185508
       _cons |    3.214994    .4001492      8.03    0.000      2.430716     3.999272
-------------+----------------------------------------------------------------


Endogenous: iq


Exogenous:  s expr tenure rns smsa med kww


.
. quietly reg lnw iq s expr tenure rns smsa

.
. estimates store ols

.
. quietly ivregress 2sls lnw s expr tenure rns smsa (iq = med kww)

.
. estimates store iv

.
. hausman iv ols,constant sigmamore


Note: the rank of the differenced variance matrix (1) does not equal the number of coefficients being tested (7); be sure this is what you expect, or there may be problems computing the test.  Examine the output of your estimators for anything unexpected and possibly consider scaling your variables so that the coefficients are on a similar scale.

                 ---- Coefficients ----
             |      (b)          (B)            (b-B)     sqrt(diag(V_b-V_B))
             |       iv          ols         Difference       Std. err.
-------------+----------------------------------------------------------------
          iq |    .0139284     .0032792        .0106493        .0054318
           s |    .0607803     .0927874        -.032007        .0163254
        expr |    .0433237     .0393443        .0039794        .0020297
      tenure |    .0296442      .034209       -.0045648        .0023283
         rns |   -.0435271    -.0745325        .0310054        .0158145
        smsa |    .1272224     .1367369       -.0095145        .0048529
       _cons |    3.218043     3.895172       -.6771285        .3453751
-------------+----------------------------------------------------------------
b = Consistent under H0 and Ha; obtained from ivregress.
B = Inconsistent under Ha, efficient under H0; obtained from regress.

Test of H0: Difference in coefficients not systematic

chi2(1)   = (b-B)'[(V_b-V_B)^(-1)](b-B)
   = 3.84
Prob > chi2   = 0.0499
(V_b-V_B is not positive definite)

.
. estat endogenous

  Tests of endogeneity
  H0: Variables are exogenous

  Durbin (score) chi2(1)          =  3.87962  (p = 0.0489)
  Wu-Hausman F(1,750)             =  3.85842  (p = 0.0499)

.
. qui reg lnw s expr tenure rns smsa,r

.
. est sto ols_no_iq

.
. qui reg lnw iq s expr tenure rns smsa,r

.
. est sto ols_with_iq

.
. qui ivregress 2sls lnw s expr tenure rns smsa (iq=med kww),r

.
. est sto tsls

.
. qui ivregress liml lnw s expr tenure rns smsa (iq=med kww),r

.
. est sto liml

.
. estimates table ols_no_iq ols_with_iq tsls liml,b se

-------------+----------------------------------------------------
Variable   | ols_no_iq     ols_with~q     tsls     liml
-------------+----------------------------------------------------
           s | .10264304     .09278735     .06078035     .06063623
             | .00620988     .00697626     .01895051     .01903397
        expr | .0381189     .03934425     .04332367     .04334159
             | .00661439     .00666033     .00741179     .0074185
      tenure | .03561456     .03420896     .02964421     .02962365
             | .00799884     .00789567     .00831697     .00832297
         rns | -.08407974     -.07453249     -.04352713     -.04338751
             | .02953295     .02997719     .03447789     .03452902
        smsa | .13966664     .13673691     .12722244     .1271796
             | .02805598     .02777116     .02974144     .02975994
          iq |      .00327916     .01392844     .01397639
             |      .00113212     .00603931     .00606812
       _cons | 4.103675     3.8951718     3.2180433     3.2149943
             | .08766646     .11592863     .39836829     .40014925
-------------+----------------------------------------------------
Legend: b/se

.
. estimates table ols_no_iq ols_with_iq tsls liml,star(0.1 0.05 0.01)

-------------+----------------------------------------------------------------
Variable   | ols_no_iq     ols_with_iq     tsls     liml
-------------+----------------------------------------------------------------
           s | .10264304  ***     .09278735  ***     .06078035  ***     .06063623  ***
        expr | .0381189  ***     .03934425  ***     .04332367  ***     .04334159  ***
      tenure | .03561456  ***     .03420896  ***     .02964421  ***     .02962365  ***
         rns | -.08407974  ***     -.07453249  **     -.04352713       -.04338751
        smsa | .13966664  ***     .13673691  ***     .12722244  ***     .1271796  ***
          iq |        .00327916  ***     .01392844  **     .01397639  **
       _cons | 4.103675  ***     3.8951718  ***     3.2180433  ***     3.2149943  ***
-------------+----------------------------------------------------------------
Legend: * p<.1; ** p<.05; *** p<.01

.
. esttab ols_no_iq ols_with_iq tsls liml,se r2 mtitle star(* 0.1 ** 0.05 *** 0.01)

----------------------------------------------------------------------------
                      (1)             (2)             (3)             (4)
                ols_no_iq     ols_with_iq            tsls            liml
----------------------------------------------------------------------------
s                   0.103***       0.0928***       0.0608***       0.0606***
             (0.00621)      (0.00698)      (0.0190)      (0.0190)

expr               0.0381***       0.0393***       0.0433***       0.0433***
             (0.00661)      (0.00666)      (0.00741)      (0.00742)

tenure             0.0356***       0.0342***       0.0296***       0.0296***
             (0.00800)      (0.00790)      (0.00832)      (0.00832)

rns               -0.0841***      -0.0745**       -0.0435         -0.0434
             (0.0295)      (0.0300)      (0.0345)      (0.0345)

smsa                0.140***        0.137***        0.127***        0.127***
             (0.0281)      (0.0278)      (0.0297)      (0.0298)

iq                                0.00328***       0.0139**        0.0140**
                             (0.00113)      (0.00604)      (0.00607)

_cons               4.104***        3.895***        3.218***        3.215***
             (0.0877)      (0.116)      (0.398)      (0.400)
----------------------------------------------------------------------------
N                     758             758             758             758
R-sq                0.352           0.360           0.278           0.277
----------------------------------------------------------------------------
Standard errors in parentheses
* p<0.1, ** p<0.05, *** p<0.01

.
. esttab ols_no_iq ols_with_iq tsls liml using iv.rtf,se r2 mtitle star(* 0.1 ** 0.05 *** 0.01)
(output written to `"iv.rtf"')

. log close
      name:  <unnamed>
       log:  E:\【计量经济学及stata】\陈强计量经济学及stata应用(网课+PPT+Data)\《计量经济学及Stata应用》Data-Finished-本科计量\第10章.smcl
  log type:  smcl
 closed on:  22 Jan 2024, 00:19:18
-------------