Announcement

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

  • Margins after Ivregress with binary endogenous variable

    Dear Statalisters,

    I am using ivregress command with a binary endogenous variable.Code is given below.

    ivregress 2sls AgeatMar medu42 medu43 medu44 sibshipsize GenroleN (Compl_cl8 = Fac_School) , first

    where Ageat_Mar is continuous and Compl_cl8 is binary endogenous variable.

    I would like to calculate the predicted mean for Compl_cl8.For that, I have used margins.

    margins, dydx(Compl_cl8) atmeans

    I am afraid I am using wrong margins command. Please suggest stata code for calculation of predicted probability for binary endogenous regressor(for ivregress)

    Any further discussion on this thread will be appreciated.

  • #2
    Hello "ashish",

    I failed to reproduce the problem you mentioned

    Code:
    . webuse hsng2
    (1980 Census housing data)
    
    .  ivregress 2sls rent pcturban (hsngval = faminc i.region), first
    
    First-stage regressions
    -----------------------
    
                                                    Number of obs     =         50
                                                    F(   5,     44)   =      19.66
                                                    Prob > F          =     0.0000
                                                    R-squared         =     0.6908
                                                    Adj R-squared     =     0.6557
                                                    Root MSE          =  9253.4821
    
    ------------------------------------------------------------------------------
         hsngval |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
        pcturban |   182.2201   115.0167     1.58   0.120    -49.58092    414.0211
          faminc |   2.731324   .6818931     4.01   0.000     1.357058    4.105589
                 |
          region |
        N Cntrl  |  -5095.038   4122.112    -1.24   0.223    -13402.61    3212.533
          South  |   -1778.05   4072.691    -0.44   0.665    -9986.019    6429.919
           West  |   13413.79   4048.141     3.31   0.002     5255.296    21572.28
                 |
           _cons |  -18671.87   11995.48    -1.56   0.127    -42847.17    5503.439
    ------------------------------------------------------------------------------
    
    
    Instrumental variables (2SLS) regression          Number of obs   =         50
                                                      Wald chi2(2)    =      90.76
                                                      Prob > chi2     =     0.0000
                                                      R-squared       =     0.5989
                                                      Root MSE        =     22.166
    
    ------------------------------------------------------------------------------
            rent |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
         hsngval |   .0022398   .0003284     6.82   0.000     .0015961    .0028836
        pcturban |    .081516   .2987652     0.27   0.785     -.504053     .667085
           _cons |   120.7065   15.22839     7.93   0.000     90.85942    150.5536
    ------------------------------------------------------------------------------
    Instrumented:  hsngval
    Instruments:   pcturban faminc 2.region 3.region 4.region
    
    . margins, dydx( hsngval ) atmeans
    
    Conditional marginal effects                    Number of obs     =         50
    Model VCE    : Unadjusted
    
    Expression   : Linear prediction, predict()
    dy/dx w.r.t. : hsngval
    at           : hsngval         =       48484 (mean)
                   pcturban        =    66.94913 (mean)
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
         hsngval |   .0022398   .0003284     6.82   0.000     .0015961    .0028836
    ------------------------------------------------------------------------------
    
    . */ now, with a binary variable
    
    . gen sex = 1 in 1/30
    (20 missing values generated)
    
    . replace sex = 0 if sex ==.
    (20 real changes made)
    
    .  ivregress 2sls rent pcturban (sex = faminc i.region), first
    
    First-stage regressions
    -----------------------
    
                                                    Number of obs     =         50
                                                    F(   5,     44)   =       0.82
                                                    Prob > F          =     0.5453
                                                    R-squared         =     0.0848
                                                    Adj R-squared     =    -0.0192
                                                    Root MSE          =     0.4996
    
    ------------------------------------------------------------------------------
             sex |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
        pcturban |   .0020174   .0062099     0.32   0.747    -.0104978    .0145325
          faminc |   9.97e-06   .0000368     0.27   0.788    -.0000642    .0000842
                 |
          region |
        N Cntrl  |   .4267086   .2225565     1.92   0.062    -.0218246    .8752418
          South  |   .3300254   .2198882     1.50   0.141    -.1131302    .7731809
           West  |   .2647379   .2185627     1.21   0.232    -.1757463    .7052222
                 |
           _cons |  -.0063415   .6476467    -0.01   0.992    -1.311588    1.298905
    ------------------------------------------------------------------------------
    
    
    Instrumental variables (2SLS) regression          Number of obs   =         50
                                                      Wald chi2(2)    =      25.79
                                                      Prob > chi2     =     0.0000
                                                      R-squared       =     0.3070
                                                      Root MSE        =     29.134
    
    ------------------------------------------------------------------------------
            rent |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             sex |  -12.12497   29.19343    -0.42   0.678    -69.34303    45.09309
        pcturban |   1.479511   .2919366     5.07   0.000     .9073258    2.051696
           _cons |    142.983   24.62187     5.81   0.000     94.72502     191.241
    ------------------------------------------------------------------------------
    Instrumented:  sex
    Instruments:   pcturban faminc 2.region 3.region 4.region
    
    . margins, dydx( sex ) atmeans
    
    Conditional marginal effects                    Number of obs     =         50
    Model VCE    : Unadjusted
    
    Expression   : Linear prediction, predict()
    dy/dx w.r.t. : sex
    at           : sex             =          .6 (mean)
                   pcturban        =    66.94913 (mean)
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             sex |  -12.12497   29.19343    -0.42   0.678    -69.34303    45.09309
    ------------------------------------------------------------------------------
    Also to remark, the command suggested by you gives the same information already presented in the regular output.

    Best regards,

    Marcos

    Comment


    • #3
      Dear Marcos,

      Thanks for the reply. I also found that, it is reproducing the results even after using margins command. Can you suggest a stata command for calculating predicted probability after ivregress.

      Comment


      • #4
        You may wish to type

        Code:
        . help ivregress postestimation
        There, you will find the - predict - command and, what is more, the options.
        Best regards,

        Marcos

        Comment

        Working...
        X