Announcement

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

  • Logit estimation - Margins - not estimable

    Dear forum members,

    I face the following issue. I am running a logit regression on survey data (individual women from two periods (pre and post 2009) and in two treatment areas (non-BH and BH). This is done in a difference-in-difference setting so at the end I am explicitly interested in the interaction effect.
    My function is specified in three ways (basic model, basic+state dummies, basic+state dummies+control variables). By including a factor variable i.surveystate I want to account for state fixed effects. When running my logit regression everything works out fine. As soon as I try to make use of any margins command (e.g. margins, dydx(*); margins, at()) Stata states the marginal effect for the indicator BH (i.BH (dummy)) and for all the different values of the state indicator (i.surveyystate (factor)) are "not estimable". This only happens in model 2 and 3 while Stata supplies me with the marginal effect of BH in model 1. While Stata says the marginal effects for BH and surveystates are not estimable in model 2 and 3 it does give me the marginal effect of other dummy/factor variables though (e.g. muslim, literacy, wealthindex). Below you can find the three model codes I have used as well as the output from model 1 and model 3. Here my issues are shown. Based on this problem I am also not able to use many other commands like mcp, marginsplot etc. as the result of margins for BH is always non estimable. Later I also want to run a model with a binary#continous interaction and face the same issue. This happens no matter if I calculate the interaction effect by hand post2009TPXBH=(post2009TP*BH) or use the factor and # notation (Model 1 as an example of pre-calculated interaction effect, model 3 example of factor notation to crate interaction effect).

    Any held would be greatly appreciated!
    Kind regards Caspar

    Model 1:
    Code:
    svy:logit teenpreg i.BH i.post2009TP i.post2009TPXBH
    margins, dydx(*) vce(unconditional)
    Model 2:
    Code:
    svy:logit teenpreg i.BH i.post2009TP i.post2009TP#i.BH i.surveystate
    margins, dydx(*) vce(unconditional)
    Model 3:
    Code:
    svy: logit teenpreg i.BH i.post2009TP i.post2009TP#i.BH i.muslim i.urban i.kanuri i.hhheadmale i.literacy i.wealthindex i.edulevel c.eduyears i.edulevelpartner c.eduyearspartner i.polygamoushh i.surveystate
    margins, dydx(*) vce(unconditional)
    Example Model 1:
    Code:
    . svy:logit teenpreg i.BH i.post2009TP i.post2009TPXBH
    (running logit on estimation sample)
    
    Survey: Logistic regression
    
    Number of strata   =       148             Number of obs     =          22,035
    Number of PSUs     =     2,269             Population size   =  22,012,938,401
                                               Design df         =           2,121
                                               F(   3,   2119)   =          124.16
                                               Prob > F          =          0.0000
    
    ---------------------------------------------------------------------------------
                    |             Linearized
           teenpreg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    ----------------+----------------------------------------------------------------
               1.BH |    1.28489   .0830362    15.47   0.000      1.12205    1.447731
       1.post2009TP |  -.2222882   .0485641    -4.58   0.000    -.3175264   -.1270499
    1.post2009TPXBH |   -.444609   .1087976    -4.09   0.000    -.6579702   -.2312479
              _cons |   -.341325   .0321343   -10.62   0.000    -.4043431   -.2783069
    ---------------------------------------------------------------------------------
    Code:
    . margins, dydx(*) vce(unconditional)
    
    Average marginal effects                        Number of obs     =     22,035
    
    Expression   : Pr(teenpreg), predict()
    dy/dx w.r.t. : 1.BH 1.post2009TP 1.post2009TPXBH
    
    ---------------------------------------------------------------------------------
                    |             Linearized
                    |      dy/dx   Std. Err.      t    P>|t|     [95% Conf. Interval]
    ----------------+----------------------------------------------------------------
               1.BH |   .3059899   .0175181    17.47   0.000     .2716355    .3403444
       1.post2009TP |  -.0521801   .0113664    -4.59   0.000    -.0744706   -.0298896
    1.post2009TPXBH |  -.0996184   .0229866    -4.33   0.000     -.144697   -.0545398
    ---------------------------------------------------------------------------------
    Note: dy/dx for factor levels is the discrete change from the base level.
    Example Model 3:
    Code:
    . svy: logit teenpreg i.BH i.post2009TP i.post2009TP#i.BH i.muslim i.urban i.kanuri i.hhheadmale i.literacy i.wealthindex i.edulevel c.eduyears i.edulevelpartner c.eduyearspartner i.polygamoushh i.surveystate
    (running logit on estimation sample)
    
    note: 1011.surveystate omitted because of collinearity
    
    Survey: Logistic regression
    
    Number of strata   =       148             Number of obs     =          14,387
    Number of PSUs     =     2,179             Population size   =  14,146,244,185
                                               Design df         =           2,031
                                               F(  52,   1980)   =           31.06
                                               Prob > F          =          0.0000
    
    -----------------------------------------------------------------------------------
                      |             Linearized
             teenpreg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    ------------------+----------------------------------------------------------------
                 1.BH |   .2549566   .1734003     1.47   0.142    -.0851043    .5950176
         1.post2009TP |  -.3188818   .0525346    -6.07   0.000    -.4219091   -.2158545
                      |
        post2009TP#BH |
                 1 1  |  -.0673073   .1045352    -0.64   0.520    -.2723146       .1377
                      |
             1.muslim |   .3358439   .0803647     4.18   0.000     .1782381    .4934497
              1.urban |   .0831391   .0599677     1.39   0.166    -.0344655    .2007437
             1.kanuri |  -.2364794    .158307    -1.49   0.135    -.5469404    .0739816
         1.hhheadmale |   .1217891   .0831064     1.47   0.143    -.0411937    .2847718
           1.literacy |   .0651338   .0817359     0.80   0.426    -.0951611    .2254287
                      |
          wealthindex |
              poorer  |   .0918043   .0657692     1.40   0.163    -.0371779    .2207864
              middle  |  -.0885208   .0767987    -1.15   0.249    -.2391332    .0620915
              richer  |  -.2907834   .0869054    -3.35   0.001    -.4612165   -.1203504
             richest  |  -.8785281   .1157358    -7.59   0.000    -1.105501   -.6515549
                      |
           1.edulevel |  -.1782213   .1062559    -1.68   0.094    -.3866034    .0301607
             eduyears |  -.0665808   .0120163    -5.54   0.000    -.0901464   -.0430153
    1.edulevelpartner |   .1496471   .1040683     1.44   0.151    -.0544445    .3537388
      eduyearspartner |  -.0227653   .0111104    -2.05   0.041    -.0445543   -.0009763
       1.polygamoushh |  -.0330811   .0575886    -0.57   0.566      -.14602    .0798577
                      |
          surveystate |
             zamfara  |  -.1928214    .151785    -1.27   0.204     -.490492    .1048492
             katsina  |   .2620451   .1615701     1.62   0.105    -.0548152    .5789055
              jigawa  |   .3076793   .1573823     1.95   0.051    -.0009681    .6163268
                yobe  |  -.0157629   .1642379    -0.10   0.924    -.3378553    .3063295
               borno  |   .0095577   .1618743     0.06   0.953    -.3078993    .3270147
             adamawa  |  -.2877648   .1631481    -1.76   0.078    -.6077198    .0321902
               gombe  |   .0768753   .1462841     0.53   0.599    -.2100072    .3637578
              bauchi  |   .3715389   .1514305     2.45   0.014     .0745636    .6685142
                kano  |   .0891833   .1387662     0.64   0.520    -.1829557    .3613223
              kaduna  |          0  (omitted)
               kebbi  |  -.0766893   .1538785    -0.50   0.618    -.3784654    .2250869
               niger  |  -.3141513   .1534187    -2.05   0.041    -.6150257   -.0132768
               abuja  |  -.4034342   .1915664    -2.11   0.035    -.7791213    -.027747
            nasarawa  |  -.0566398   .2138995    -0.26   0.791    -.4761251    .3628455
             plateau  |    -.32141   .1756258    -1.83   0.067    -.6658354    .0230155
              taraba  |   .1213225   .1683685     0.72   0.471    -.2088706    .4515155
               benue  |  -.0591002   .1748634    -0.34   0.735    -.4020306    .2838302
                kogi  |    .432422   .2098261     2.06   0.039     .0209253    .8439188
               kwara  |  -.4152658     .19115    -2.17   0.030    -.7901363   -.0403952
                 oyo  |  -.0257761   .1844987    -0.14   0.889    -.3876026    .3360503
                osun  |  -.6566143   .1752572    -3.75   0.000    -1.000317   -.3129118
               ekiti  |   .0372496   .2635448     0.14   0.888    -.4795967    .5540958
                ondo  |  -.2915482   .2125072    -1.37   0.170     -.708303    .1252067
                 edo  |  -.3771684   .2374049    -1.59   0.112    -.8427508     .088414
             anambra  |   .0657958   .1944728     0.34   0.735    -.3155912    .4471828
               enugu  |  -.2516204   .1999433    -1.26   0.208    -.6437357    .1404949
              ebonyi  |  -.0660226   .1995881    -0.33   0.741    -.4574413    .3253961
         cross river  |   .4106171   .2347734     1.75   0.080    -.0498048    .8710389
           akwa ibom  |   .0735537    .213957     0.34   0.731    -.3460444    .4931518
                abia  |  -.3390893   .2490943    -1.36   0.174    -.8275962    .1494177
                 imo  |   -.618356   .2192515    -2.82   0.005    -1.048337   -.1883747
              rivers  |  -.0649557   .2182536    -0.30   0.766      -.49298    .3630687
             bayelsa  |   .6023436   .1887087     3.19   0.001     .2322609    .9724263
               delta  |   .0971328   .2320194     0.42   0.676     -.357888    .5521536
               lagos  |  -.5527324   .2374296    -2.33   0.020    -1.018363   -.0871015
                ogun  |  -.3748587   .1993162    -1.88   0.060    -.7657442    .0160268
                      |
                _cons |   1.085254   .1637543     6.63   0.000     .7641102    1.406398
    -----------------------------------------------------------------------------------
    Code:
    . margins, dydx(*) vce(unconditional)
    
    Average marginal effects                        Number of obs     =     14,387
    
    Expression   : Pr(teenpreg), predict()
    dy/dx w.r.t. : 1.BH 1.post2009TP 1.muslim 1.urban 1.kanuri 1.hhheadmale 1.literacy 2.wealthindex 3.wealthindex 4.wealthindex 5.wealthindex 1.edulevel eduyears 1.edulevelpartner eduyearspartner 1.polygamoushh 1002.surveystate 1003.surveystate
                   1004.surveystate 1005.surveystate 1006.surveystate 1007.surveystate 1008.surveystate 1009.surveystate 1010.surveystate 1011.surveystate 1012.surveystate 1013.surveystate 1014.surveystate 1015.surveystate 1016.surveystate
                   1017.surveystate 1018.surveystate 1019.surveystate 1020.surveystate 1021.surveystate 1022.surveystate 1023.surveystate 1024.surveystate 1025.surveystate 1026.surveystate 1027.surveystate 1028.surveystate 1029.surveystate
                   1030.surveystate 1031.surveystate 1032.surveystate 1033.surveystate 1034.surveystate 1035.surveystate 1036.surveystate 1037.surveystate
    
    -----------------------------------------------------------------------------------
                      |             Linearized
                      |      dy/dx   Std. Err.      t    P>|t|     [95% Conf. Interval]
    ------------------+----------------------------------------------------------------
                 1.BH |          .  (not estimable)
         1.post2009TP |  -.0649622   .0087651    -7.41   0.000    -.0821517   -.0477727
             1.muslim |   .0665069   .0163947     4.06   0.000     .0343547    .0986591
              1.urban |   .0157526    .011258     1.40   0.162    -.0063258     .037831
             1.kanuri |  -.0462524    .031588    -1.46   0.143    -.1082006    .0156958
         1.hhheadmale |   .0235927   .0162881     1.45   0.148    -.0083504    .0555359
           1.literacy |   .0123473   .0153524     0.80   0.421    -.0177609    .0424555
                      |
          wealthindex |
              poorer  |   .0175353   .0125973     1.39   0.164    -.0071697    .0422404
              middle  |  -.0173779   .0150855    -1.15   0.249    -.0469626    .0122067
              richer  |  -.0586335   .0176686    -3.32   0.001     -.093284   -.0239831
             richest  |  -.1865903   .0255393    -7.31   0.000    -.2366762   -.1365044
                      |
           1.edulevel |  -.0350133   .0214133    -1.64   0.102    -.0770077    .0069811
             eduyears |  -.0127354   .0022819    -5.58   0.000    -.0172106   -.0082602
    1.edulevelpartner |   .0281589   .0192538     1.46   0.144    -.0096004    .0659182
      eduyearspartner |  -.0043545   .0021267    -2.05   0.041    -.0085253   -.0001837
       1.polygamoushh |  -.0063313   .0110293    -0.57   0.566    -.0279613    .0152987
                      |
          surveystate |
             zamfara  |          .  (not estimable)
             katsina  |          .  (not estimable)
              jigawa  |          .  (not estimable)
                yobe  |          .  (not estimable)
               borno  |          .  (not estimable)
             adamawa  |          .  (not estimable)
               gombe  |          .  (not estimable)
              bauchi  |          .  (not estimable)
                kano  |          .  (not estimable)
              kaduna  |          .  (not estimable)
               kebbi  |          .  (not estimable)
               niger  |          .  (not estimable)
               abuja  |          .  (not estimable)
            nasarawa  |          .  (not estimable)
             plateau  |          .  (not estimable)
              taraba  |          .  (not estimable)
               benue  |          .  (not estimable)
                kogi  |          .  (not estimable)
               kwara  |          .  (not estimable)
                 oyo  |          .  (not estimable)
                osun  |          .  (not estimable)
               ekiti  |          .  (not estimable)
                ondo  |          .  (not estimable)
                 edo  |          .  (not estimable)
             anambra  |          .  (not estimable)
               enugu  |          .  (not estimable)
              ebonyi  |          .  (not estimable)
         cross river  |          .  (not estimable)
           akwa ibom  |          .  (not estimable)
                abia  |          .  (not estimable)
                 imo  |          .  (not estimable)
              rivers  |          .  (not estimable)
             bayelsa  |          .  (not estimable)
               delta  |          .  (not estimable)
               lagos  |          .  (not estimable)
                ogun  |          .  (not estimable)
    -----------------------------------------------------------------------------------
    Note: dy/dx for factor levels is the discrete change from the base level.

  • #2
    I should add that the binary indicator BH (0/1) depends on the surveystate - meaning if an individual woman lives in certain states (seven states to be exact) she is coded as BH=1 and if not (30 other states) she is coded as BH=0. Could this be the issue if I include the BH indicator (using i.BH) and state fixed effects (using i.surveystate) in my models and try margins command? (maybe because of colinearity etc?
    If I use then suddenly all margins are presented
    Code:
    margins, dydx(*) vce unconditional noestimcheck
    Last edited by Cas Ziegler; 27 May 2020, 05:34.

    Comment


    • #3
      Perhaps #12 in this thread will answer your question.

      Comment


      • #4
        Dear Justin,

        Thank you for the link. I already informed myself as well whether I could use the -nonestim- option or not but as the #12 answer in the other thread indicates it always depends on the model. So regarding my issue Im still unsure whether I can use it or not.
        Furthermore I am really confused why one of the state indicators is omitted (Kaduna). One state (Sokoto) is already used as baseline and nontheless Stata drops another state. If I define BH differently and Kaduna does not determine BH=1 then another state like Kano is dropped. So Stata always drops one additional state although it already considers the baseline and the additionally dropped state changes depending on my model specification I ust dont know why.

        Code:
        svy: logit childmarriage i.BH i.post2009CM i.post2009CM#i.BH i.muslim i.urban i.kanuri i.hhheadmale i.literacy i.wealthindex i.edulevel c.eduyears i.edulevelpartner c.eduyearspartner i.polygamoushh i.surveystate
        margins, dydx(*) vce(unconditional) noestimcheck
        Code:
        . margins, dydx(*) vce(unconditional) noestimcheck
        
        Average marginal effects                        Number of obs     =     10,924
        
        Expression   : Pr(childmarriage), predict()
        dy/dx w.r.t. : 1.BH 1.post2009CM 1.muslim 1.urban 1.kanuri 1.hhheadmale 1.literacy 2.wealthindex 3.wealthindex 4.wealthindex 5.wealthindex 1.edulevel eduyears 1.edulevelpartner eduyearspartner 1.polygamoushh 1002.surveystate 1003.surveystate
                       1004.surveystate 1005.surveystate 1006.surveystate 1007.surveystate 1008.surveystate 1009.surveystate 1010.surveystate 1011.surveystate 1012.surveystate 1013.surveystate 1014.surveystate 1015.surveystate 1016.surveystate
                       1017.surveystate 1018.surveystate 1019.surveystate 1020.surveystate 1021.surveystate 1022.surveystate 1023.surveystate 1024.surveystate 1025.surveystate 1026.surveystate 1027.surveystate 1028.surveystate 1029.surveystate
                       1030.surveystate 1031.surveystate 1032.surveystate 1033.surveystate 1034.surveystate 1035.surveystate 1036.surveystate 1037.surveystate
        
        -----------------------------------------------------------------------------------
                          |             Linearized
                          |      dy/dx   Std. Err.      t    P>|t|     [95% Conf. Interval]
        ------------------+----------------------------------------------------------------
                     1.BH |   .0367317   .0294681     1.25   0.213    -.0210616     .094525
             1.post2009CM |  -.0200927   .0088887    -2.26   0.024    -.0375253   -.0026601
                 1.muslim |   .0674911   .0154403     4.37   0.000     .0372094    .0977728
                  1.urban |  -.0121125   .0113542    -1.07   0.286    -.0343806    .0101556
                 1.kanuri |  -.1059727   .0345604    -3.07   0.002    -.1737531   -.0381922
             1.hhheadmale |   .0054944   .0150542     0.36   0.715    -.0240302    .0350189
               1.literacy |  -.0136669    .014644    -0.93   0.351    -.0423868    .0150531
                          |
              wealthindex |
                  poorer  |   .0040656    .012783     0.32   0.750    -.0210046    .0291358
                  middle  |  -.0275005   .0144926    -1.90   0.058    -.0559237    .0009226
                  richer  |  -.0718664   .0167604    -4.29   0.000    -.1047371   -.0389956
                 richest  |  -.1309238   .0243141    -5.38   0.000    -.1786092   -.0832385
                          |
               1.edulevel |   .0300293   .0172434     1.74   0.082    -.0037888    .0638474
                 eduyears |  -.0188884   .0022215    -8.50   0.000    -.0232452   -.0145316
        1.edulevelpartner |   .0301516    .018429     1.64   0.102    -.0059917    .0662949
          eduyearspartner |  -.0069324   .0019281    -3.60   0.000    -.0107139   -.0031509
           1.polygamoushh |   -.004807    .011021    -0.44   0.663    -.0264217    .0168076
                          |
              surveystate |
                 zamfara  |  -.0402192   .0403129    -1.00   0.319    -.1192816    .0388431
                 katsina  |   .0589429   .0300539     1.96   0.050     6.93e-07     .117885
                  jigawa  |   .0232868   .0311095     0.75   0.454    -.0377256    .0842993
                    yobe  |  -.0528482   .0308714    -1.71   0.087    -.1133938    .0076974
                   borno  |  -.0133272   .0336918    -0.40   0.692    -.0794042    .0527498
                 adamawa  |  -.1548828   .0361367    -4.29   0.000    -.2257548   -.0840109
                   gombe  |   .0366776   .0284905     1.29   0.198    -.0191984    .0925537
                  bauchi  |   .0409627   .0300163     1.36   0.173    -.0179057    .0998312
                    kano  |          0  (omitted)
                  kaduna  |   .0191752   .0308333     0.62   0.534    -.0412956    .0796459
                   kebbi  |  -.0477807   .0353107    -1.35   0.176    -.1170326    .0214712
                   niger  |  -.1426839   .0335254    -4.26   0.000    -.2084345   -.0769332
                   abuja  |   -.062605   .0412462    -1.52   0.129    -.1434978    .0182877
                nasarawa  |  -.0491596   .0398547    -1.23   0.218    -.1273233    .0290042
                 plateau  |  -.1900547   .0408006    -4.66   0.000    -.2700735   -.1100358
                  taraba  |  -.0514885   .0325106    -1.58   0.113    -.1152488    .0122718
                   benue  |  -.1000236   .0374978    -2.67   0.008     -.173565   -.0264821
                    kogi  |   .0411736   .0340585     1.21   0.227    -.0256227    .1079698
                   kwara  |  -.2592855   .0430805    -6.02   0.000    -.3437759   -.1747952
                     oyo  |  -.1228631   .0401557    -3.06   0.002    -.2016171    -.044109
                    osun  |  -.2036991   .0462033    -4.41   0.000    -.2943138   -.1130845
                   ekiti  |  -.0733964   .0416274    -1.76   0.078    -.1550368    .0082441
                    ondo  |  -.1292965   .0497833    -2.60   0.009    -.2269324   -.0316606
                     edo  |  -.1114323   .0485046    -2.30   0.022    -.2065603   -.0163042
                 anambra  |  -.0960398   .0414668    -2.32   0.021    -.1773651   -.0147144
                   enugu  |  -.1701812   .0517377    -3.29   0.001    -.2716501   -.0687122
                  ebonyi  |  -.1511242   .0460934    -3.28   0.001    -.2415234    -.060725
             cross river  |  -.1219984   .0510889    -2.39   0.017    -.2221949   -.0218018
               akwa ibom  |  -.1320105    .048723    -2.71   0.007    -.2275669    -.036454
                    abia  |  -.1047756   .0493649    -2.12   0.034     -.201591   -.0079602
                     imo  |  -.1272357   .0514324    -2.47   0.013    -.2281058   -.0263656
                  rivers  |  -.0736287   .0395962    -1.86   0.063    -.1512854     .004028
                 bayelsa  |   .0436643    .034375     1.27   0.204    -.0237525    .1110811
                   delta  |  -.0180106   .0410776    -0.44   0.661    -.0985727    .0625514
                   lagos  |  -.1997359   .0637448    -3.13   0.002    -.3247534   -.0747185
                    ogun  |  -.1760224   .0453265    -3.88   0.000    -.2649175   -.0871273
        -----------------------------------------------------------------------------------
        Note: dy/dx for factor levels is the discrete change from the base level.

        Comment

        Working...
        X