Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hausman specification test 2sls vs 3sls in stata 18.0

    Dear all
    How to perfomer Hausman specification test 2sls vs 3sls in stata 18.0.
    Someone can help with comand,
    Best regards
    José tavares

  • #2
    help ivreg2

    word search for Hausman.

    Comment


    • #3
      Not sure that you can estimate a 3sls model with ivreg2 from SSC. There are two issues: Stata's reg3 command and the hausman command do not have options for robust standard errors. These are needed for a large number of empirical analyses. If you can ignore this, here is how you can implement the test. This is based on Kmenta's (1986) dataset, also discussed at https://cran.r-project.org/web/packa.../systemfit.pdf (p. 27).
      Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	151.1 KB
ID:	1761200



      In this example, the test statistic had 7 degrees of freedom, implying that the Hausman test includes the constants from 2sls and 3sls in the test. Stata's results are equivalent to those obtained here.


      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input float(consump price income farmPrice) byte trend
       98.485 100.323  87.4    98  1
       99.187 104.264  97.6  99.1  2
      102.163 103.435  96.7  99.1  3
      101.504 104.506  98.2  98.1  4
       104.24  98.001  99.8 110.8  5
      103.243  99.456 100.5 108.2  6
      103.993 101.066 103.2 105.6  7
         99.9 104.763 107.8 109.8  8
       100.35  96.446  96.6 108.7  9
       102.82  91.228  88.9 100.6 10
       95.435  93.085  75.1    81 11
       92.424  98.801  76.9  68.6 12
       94.535 102.908  84.6  70.9 13
       98.757  98.756  90.6  81.4 14
      105.797  95.119 103.1 102.3 15
      100.225  98.451 105.1   105 16
      103.522  86.498  96.4 110.5 17
       99.929 104.016 104.4  92.5 18
      105.223 105.769 110.7  89.3 19
      106.232  113.49 127.1    93 20
      end
      label var consump "food consumption per capita"
      label var price "ratio of food prices to general consumer prices"
      label var income "disposable income in constant dollars"
      label var farmPrice "ratio of preceding year's prices received by farmers to general consumer prices"
      label var trend "time trend in years"
      
      global demand "(qDemand: consump price income)"
      global supply "(qSupply: consump price farmPrice trend)"
      reg3 $demand $supply, endog(consump price) 2sls
      est sto _2sls
      reg3 $demand $supply, endog(consump price) 3sls
      hausman _2sls ., alleq cons
      Res.:

      Code:
      . reg3 $demand $supply, endog(consump price) 2sls
      
      Two-stage least-squares regression
      ------------------------------------------------------------------------------
      Equation             Obs   Params         RMSE  "R-squared"         F      P>F
      ------------------------------------------------------------------------------
      qDemand               20        2      1.96632      0.7548      23.81   0.0000
      qSupply               20        3     2.457555      0.6396      10.70   0.0000
      ------------------------------------------------------------------------------
      
      ------------------------------------------------------------------------------
                   | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
      -------------+----------------------------------------------------------------
      qDemand      |
             price |  -.2435564   .0964843    -2.52   0.017    -.4398551   -.0472577
            income |   .3139917   .0469436     6.69   0.000     .2184842    .4094993
             _cons |    94.6333   7.920836    11.95   0.000     78.51824    110.7484
      -------------+----------------------------------------------------------------
      qSupply      |
             price |   .2400757   .0999338     2.40   0.022     .0367588    .4433927
         farmPrice |   .2556056   .0472501     5.41   0.000     .1594747    .3517366
             trend |   .2529243   .0996551     2.54   0.016     .0501745     .455674
             _cons |   49.53245   12.01052     4.12   0.000     25.09686    73.96805
      ------------------------------------------------------------------------------
      Note: Small-sample degrees-of-freedom adjustment applied when estimating
            covariance matrix of residuals.
      Endogenous: consump price
      Exogenous:  income farmPrice trend
      
      .
      . est sto _2sls
      
      .
      . reg3 $demand $supply, endog(consump price) 3sls
      
      Three-stage least-squares regression
      ------------------------------------------------------------------------------
      Equation             Obs   Params         RMSE  "R-squared"      chi2   P>chi2
      ------------------------------------------------------------------------------
      qDemand               20        2     1.812857      0.7548      56.02   0.0000
      qSupply               20        3     2.315341      0.6001      38.20   0.0000
      ------------------------------------------------------------------------------
      
      ------------------------------------------------------------------------------
                   | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
      -------------+----------------------------------------------------------------
      qDemand      |
             price |  -.2435564   .0889541    -2.74   0.006    -.4179033   -.0692096
            income |   .3139917   .0432799     7.25   0.000     .2291647    .3988188
             _cons |    94.6333    7.30265    12.96   0.000     80.32037    108.9462
      -------------+----------------------------------------------------------------
      qSupply      |
             price |   .2289322   .0891504     2.57   0.010     .0542006    .4036637
         farmPrice |   .2289775   .0393492     5.82   0.000     .1518544    .3061006
             trend |   .3579074   .0651942     5.49   0.000      .230129    .4856857
             _cons |   52.11765   10.63775     4.90   0.000     31.26804    72.96726
      ------------------------------------------------------------------------------
      Endogenous: consump price
      Exogenous:  income farmPrice trend
      
      .
      . hausman _2sls ., alleq cons
      
                       ---- Coefficients ----
                   |      (b)          (B)            (b-B)     sqrt(diag(V_b-V_B))
                   |     _2sls          .          Difference       Std. err.
      -------------+----------------------------------------------------------------
      qDemand      |
             price |   -.2435564    -.2435564       -7.11e-15        .0373682
            income |    .3139917     .3139917        7.11e-14        .0181812
             _cons |     94.6333      94.6333       -1.09e-11        3.067726
      -------------+----------------------------------------------------------------
      qSupply      |
             price |    .2400757     .2289322        .0111436        .0451551
         farmPrice |    .2556056     .2289775        .0266282        .0261573
             trend |    .2529243     .3579074       -.1049831        .0753714
             _cons |    49.53245     52.11765       -2.585195        5.575921
      ------------------------------------------------------------------------------
                                 b = Consistent under H0 and Ha; obtained from reg3.
                  B = Inconsistent under Ha, efficient under H0; obtained from reg3.
      
      Test of H0: Difference in coefficients not systematic
      
         chi2(7) = (b-B)'[(V_b-V_B)^(-1)](b-B)
                  =   2.28
      Prob > chi2 = 0.9426

      Comment


      • #4
        thank you so much

        Comment


        • #5
          Thanks, it works ok.. Nice advice. I Just running the model.
          Works perfectly.
          Thank you once again
          Best regards

          Comment

          Working...
          X