Stata Textbook Examples
Econometric Analysis, Fourth Edition by William Greene
Selected Portions of Chapter 16: Simultaneous-Equations Models

use "http://www.ats.ucla.edu/stat/stata/examples/greene/TBL16-2.DTA", clear

generate w = wg+wp
generate k = k1+i
generate yr=year-1931
generate p1 = p[_n-1] 
generate x1 = x[_n-1]
save table16-2
Table 16.4, OLS, page 687.
regress c p p1 w

      Source |       SS       df       MS              Number of obs =      21
-------------+------------------------------           F(  3,    17) =  292.71
       Model |  923.549937     3  307.849979           Prob > F      =  0.0000
    Residual |  17.8794524    17  1.05173249           R-squared     =  0.9810
-------------+------------------------------           Adj R-squared =  0.9777
       Total |  941.429389    20  47.0714695           Root MSE      =  1.0255

------------------------------------------------------------------------------
           c |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
           p |   .1929343   .0912102     2.12   0.049     .0004977     .385371
          p1 |   .0898847   .0906479     0.99   0.335    -.1013658    .2811351
           w |   .7962188   .0399439    19.93   0.000     .7119444    .8804931
       _cons |    16.2366   1.302698    12.46   0.000     13.48815    18.98506
------------------------------------------------------------------------------
Table 16.4, 2SLS using reg3, page 687.
reg3 (c p p1 w), 2sls nodfk inst(t wg g yr p1 x1 k1)

Two-stage least-squares regression
----------------------------------------------------------------------
Equation          Obs  Parms        RMSE    "R-sq"     F-Stat        P
----------------------------------------------------------------------
c                  21      3    1.135659    0.9767   279.0941   0.0000
----------------------------------------------------------------------

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
c            |
           p |   .0173022   .1180494     0.15   0.885    -.2317603    .2663647
          p1 |   .2162338    .107268     2.02   0.060    -.0100818    .4425495
           w |   .8101827   .0402497    20.13   0.000     .7252632    .8951022
       _cons |   16.55476   1.320793    12.53   0.000     13.76813    19.34139
------------------------------------------------------------------------------
Endogenous variables:  c p w 
Exogenous variables:   t wg g yr p1 x1 k1 
------------------------------------------------------------------------------
Table 16.4, 2SLS using ivreg, page 687. The initial ivreg produces the correct coefficients but the standard errors are wrong. Additional code is necessary to obtain the correct standard errors.
ivreg c p1 (p w = t wg g yr p1 x1 k1)

Instrumental variables (2SLS) regression

      Source |       SS       df       MS              Number of obs =      21
-------------+------------------------------           F(  3,    17) =  225.93
       Model |  919.504138     3  306.501379           Prob > F      =  0.0000
    Residual |  21.9252518    17  1.28972069           R-squared     =  0.9767
-------------+------------------------------           Adj R-squared =  0.9726
       Total |  941.429389    20  47.0714695           Root MSE      =  1.1357

------------------------------------------------------------------------------
           c |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
           p |   .0173022   .1312046     0.13   0.897    -.2595153    .2941197
           w |   .8101827   .0447351    18.11   0.000        .7158    .9045654
          p1 |   .2162338   .1192217     1.81   0.087    -.0353019    .4677696
       _cons |   16.55476   1.467979    11.28   0.000     13.45759    19.65192
------------------------------------------------------------------------------
Instrumented:  p w
Instruments:   p1 t wg g yr x1 k1
------------------------------------------------------------------------------

/* additional code to get correct standard errors, thanks to Kit Baum */
mat vpr=e(V)*e(df_r)/e(N)
mat se=e(b)
local nc=colsof(se)
forv i=1/`nc' { mat se[1,`i']=sqrt(vpr[`i',`i']) }
mat list se

se[1,4]
            p          w         p1      _cons
y1  .11804942  .04024972  .10726797  1.3207925
Table 16.4, GMM, page 687. Uses ivgmm0 by Christopher F. Baum and David M. Drukker, available from SSC-Ideas. The program ivgmm0 can be downloaded typing findit ivgmm0 in the command line (see How can I use the findit command to search for programs and get additional help? for more information about using findit). The standard errors are the same as Greene but the coefficients are slightly different. Results identical to Stata are produced by the program TSP. Some researchers suggest that Greene's coefficients are due to the fact that he uses the results from prior analyses as his starting values.
ivgmm0 c p1 (p w = t wg g yr p1 x1 k1)

Instrumental Variables Estimation via GMM           Number of obs  =        21
                                                    Root MSE       =    1.0255
                                                    Hansen J       =    4.1098
                                                    Chi-sq( 4) P-val = 0.39135
------------------------------------------------------------------------------
             |                 GMM
           c |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
           p |   .0757916   .0615982     1.23   0.219    -.0449386    .1965218
           w |   .8493653   .0292499    29.04   0.000     .7920365    .9066941
          p1 |   .1662683   .0654933     2.54   0.011     .0379039    .2946327
       _cons |   14.74433   .8966058    16.44   0.000     12.98702    16.50165
------------------------------------------------------------------------------
Instrumented:  p w
Instruments:   p1 t wg g yr x1 k1
------------------------------------------------------------------------------
Table 16.4, LIML, page 687. Currently there is no Stata solution for the LIML model.
Table 16.5, 2SLS, page 699.
reg3 (c p p1 w) (i p p1 k1) (wp x x1 yr), 2sls nodfk inst(t wg g yr p1 x1 k1)

Two-stage least-squares regression
----------------------------------------------------------------------
Equation          Obs  Parms        RMSE    "R-sq"     F-Stat        P
----------------------------------------------------------------------
c                  21      3    1.135659    0.9767   279.0941   0.0000
i                  21      3    1.307149    0.8849   50.89437   0.0000
wp                 21      3    .7671548    0.9874    524.005   0.0000
----------------------------------------------------------------------

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
c            |
           p |   .0173022   .1180494     0.15   0.884    -.2196919    .2542963
          p1 |   .2162338    .107268     2.02   0.049     .0008844    .4315833
           w |   .8101827   .0402497    20.13   0.000      .729378    .8909874
       _cons |   16.55476   1.320793    12.53   0.000     13.90316    19.20636
-------------+----------------------------------------------------------------
i            |
           p |   .1502219   .1732292     0.87   0.390    -.1975503    .4979941
          p1 |   .6159434   .1627853     3.78   0.000     .2891382    .9427486
          k1 |  -.1577876   .0361262    -4.37   0.000    -.2303141   -.0852612
       _cons |   20.27821   7.542704     2.69   0.010     5.135599    35.42082
-------------+----------------------------------------------------------------
wp           |
           x |   .4388591   .0356319    12.32   0.000     .3673251    .5103931
          x1 |   .1466739   .0388361     3.78   0.000     .0687071    .2246406
          yr |   .1303956    .029141     4.47   0.000     .0718927    .1888985
       _cons |   1.500296   1.147779     1.31   0.197    -.8039674    3.804559
------------------------------------------------------------------------------
Endogenous variables:  c p w i wp x 
Exogenous variables:   t wg g yr p1 x1 k1 
------------------------------------------------------------------------------
Table 16.5, OLS, page 699.
reg3 (c p p1 w) (i p p1 k1) (wp x x1 yr), ols

Multivariate regression
----------------------------------------------------------------------
Equation          Obs  Parms        RMSE    "R-sq"     F-Stat        P
----------------------------------------------------------------------
c                  21      3     1.02554    0.9810   292.7075   0.0000
i                  21      3    1.009447    0.9313   76.87538   0.0000
wp                 21      3    .7671466    0.9874   444.5687   0.0000
----------------------------------------------------------------------

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
c            |
           p |   .1929343   .0912102     2.12   0.039     .0098223    .3760464
          p1 |   .0898847   .0906479     0.99   0.326    -.0920987     .271868
           w |   .7962188   .0399439    19.93   0.000      .716028    .8764095
       _cons |    16.2366   1.302698    12.46   0.000     13.62133    18.85188
-------------+----------------------------------------------------------------
i            |
           p |   .4796356   .0971146     4.94   0.000       .28467    .6746012
          p1 |   .3330387   .1008592     3.30   0.002     .1305554     .535522
          k1 |  -.1117947   .0267276    -4.18   0.000    -.1654525   -.0581369
       _cons |   10.12579   5.465546     1.85   0.070    -.8467492    21.09833
-------------+----------------------------------------------------------------
wp           |
           x |   .4394769   .0324076    13.56   0.000      .374416    .5045378
          x1 |     .14609   .0374231     3.90   0.000       .07096      .22122
          yr |   .1302452   .0319103     4.08   0.000     .0661826    .1943077
       _cons |   1.497043   1.270031     1.18   0.244    -1.052651    4.046737
------------------------------------------------------------------------------
Table 16.5, 3SLS, page 699.
reg3 (c p p1 w) (i p p1 k1) (wp x x1 yr), 3sls inst(t wg g yr p1 x1 k1)

Three-stage least squares regression
----------------------------------------------------------------------
Equation          Obs  Parms        RMSE    "R-sq"       chi2        P
----------------------------------------------------------------------
c                  21      3    .9443305    0.9801   864.5909   0.0000
i                  21      3    1.446736    0.8258   162.9808   0.0000
wp                 21      3    .7211282    0.9863   1594.751   0.0000
----------------------------------------------------------------------

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
c            |
           p |   .1248904   .1081291     1.16   0.248    -.0870387    .3368194
          p1 |   .1631439   .1004382     1.62   0.104    -.0337113    .3599992
           w |    .790081   .0379379    20.83   0.000      .715724    .8644379
       _cons |   16.44079   1.304549    12.60   0.000     13.88392    18.99766
-------------+----------------------------------------------------------------
i            |
           p |  -.0130791   .1618962    -0.08   0.936    -.3303898    .3042316
          p1 |   .7557238   .1529331     4.94   0.000     .4559805    1.055467
          k1 |  -.1948482   .0325307    -5.99   0.000    -.2586072   -.1310893
       _cons |   28.17785   6.793768     4.15   0.000     14.86231    41.49339
-------------+----------------------------------------------------------------
wp           |
           x |   .4004919   .0318134    12.59   0.000     .3381388     .462845
          x1 |    .181291   .0341588     5.31   0.000     .1143411    .2482409
          yr |    .149674   .0279352     5.36   0.000      .094922    .2044261
       _cons |   1.797216   1.115854     1.61   0.107    -.3898181    3.984251
------------------------------------------------------------------------------
Endogenous variables:  c p w i wp x 
Exogenous variables:   t wg g yr p1 x1 k1 
------------------------------------------------------------------------------
Table 16.5, I3SLS, page 699.
reg3 (c p p1 w) (i p p1 k1) (wp x x1 yr), 3sls ireg3 inst(t wg g yr p1 x1 k1)

Iteration 1:   tolerance =  .37125491
..
Iteration 24:   tolerance =  7.049e-07

Three-stage least squares regression, iterated 
----------------------------------------------------------------------
Equation          Obs  Parms        RMSE    "R-sq"       chi2        P
----------------------------------------------------------------------
c                  21      3    .9565088    0.9796   970.3072   0.0000
i                  21      3    2.134327    0.6209   56.77951   0.0000
wp                 21      3    .7782334    0.9840   1312.188   0.0000
----------------------------------------------------------------------

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
c            |
           p |   .1645096   .0961979     1.71   0.087    -.0240348    .3530539
          p1 |   .1765639   .0901001     1.96   0.050    -.0000291    .3531569
           w |   .7658011   .0347599    22.03   0.000     .6976729    .8339294
       _cons |   16.55899   1.224401    13.52   0.000     14.15921    18.95877
-------------+----------------------------------------------------------------
i            |
           p |  -.3565316   .2601568    -1.37   0.171    -.8664296    .1533664
          p1 |   1.011299   .2487745     4.07   0.000     .5237098    1.498888
          k1 |     -.2602   .0508694    -5.12   0.000    -.3599022   -.1604978
       _cons |   42.89629   10.59386     4.05   0.000     22.13271    63.65987
-------------+----------------------------------------------------------------
wp           |
           x |   .3747792   .0311027    12.05   0.000     .3138191    .4357394
          x1 |   .1936506   .0324018     5.98   0.000     .1301443     .257157
          yr |   .1679262   .0289291     5.80   0.000     .1112263    .2246261
       _cons |   2.624766   1.195559     2.20   0.028     .2815124    4.968019
------------------------------------------------------------------------------
Endogenous variables:  c p w i wp x 
Exogenous variables:   t wg g yr p1 x1 k1 
------------------------------------------------------------------------------
Table 16.5, page 699. Currently there are not Stata solutions for the LIML, FIML, GMM (H2SLS) and GMM (H3SLS) models.

How to cite this page

Report an error on this page or leave a comment

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.