Announcement

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

  • Esttab command: export of odds ratios from a multilevel logit regression

    Dear everyone,


    I am using esttab command in Stata 14.2 to export results of multilevel mixed effects logit regressions to a MS Word table. I have one binary dependent variable, eight explanatory variables on the individual level, and two one the group (in this case country) level. The code I am using is below:

    Code:
    eststo clear
    eststo: xtmelogit dV var1 var2 var3 var4 var5 var6 var7 var 8 || groupidentifier:, or
    eststo: xtmelogit dV var1 var2 var3 var4 var5 var6 var7 var8 || groupidentifier: groupvar1, or cov(unstruct)
    eststo: xtmelogit dV var1 var2 var3 var4 var5 var6 var7 var8 || groupidentifier: groupvar2, or cov(unstruct)
    esttab, se wide transform(ln*: exp(@) exp(@))
    esttab, eform t, using MML_logit_1.rtf, replace
    As you can see (eform t), I want odds ratios as a final result. Moreover, I want it in a form of a table in MS word.
    ---

    As additional background information, please find results:

    a) in Stata (before transformation to odds ratios)
    b) in MS Word (after transformation)


    Code:
    ---------------------------------------------------------------------------------------------------
                           (1)                          (2)                                      (3)                
                           dV                          dV                                        dV            
    ---------------------------------------------------------------------------------------------------
    eq1                                                                                                
    var1    -0.149***     (0.0190)       -0.150***    (0.0190)        -0.149***     (0.0190)
    var2     -0.0173        (0.0262)      -0.0172      (0.0262)       -0.0173       (0.0262)
    var3      0.115***     (0.0163)        0.116***     (0.0163)        0.115***     (0.0163)
    var4      0.118***     (0.0235)        0.118***     (0.0234)        0.118***     (0.0235)
    var5    -0.00388       (0.00693)    -0.00396     (0.00693)     -0.00388    (0.00693)
    var6     0.0793***    (0.00724)     0.0792***    (0.00724)      0.0793***  (0.00724)
    var7     0.0161        (0.0152)       0.0162        (0.0152)        0.0162       (0.0152)
    var8     -0.0856**      (0.0300)     -0.0854**    (0.0300)       -0.0858**    (0.0300)
    _cons   -0.0946         (0.144)      -0.176         (0.141)         -0.0958        (0.144)
    ---------------------------------------------------------------------------------------------------
    lns1_1_1                                                                                          
    _cons               0.400*** (0.0544)    0.0119*** (0.00473)      0.00342** (0.00739)
    ---------------------------------------------------------------------------------------------------
    lns1_1_2                                                                                          
    _cons                                            0.485         (0.184)        0.338**       (0.135)
    ---------------------------------------------------------------------------------------------------
    atr1_1_1_2                                                                                        
    _cons                                           -1.287*        (0.643)        7.058        (2623.0)
    ---------------------------------------------------------------------------------------------------
    N                   20696                        20696                        20696                
    ---------------------------------------------------------------------------------------------------
    Standard errors in parentheses
    * p<0.05, ** p<0.01, *** p<0.001



    b)
    Code:
     
    (1) (2) (3)
    dV dV dV
    eq1
    Var1 0.861*** 0.861*** 0.862***
    (-7.84) (-7.87) (-7.84)
    Var2 0.983 0.983 0.983
    (-0.66) (-0.66) (-0.66)
    Var3 1.122*** 1.122*** 1.122***
    (7.07) (7.08) (7.07)
    Var4 1.125*** 1.125*** 1.125***
    (5.03) (5.02) (5.01)
    Var5 0.996 0.996 0.996
    (-0.56) (-0.57) (-0.56)
    Var6 1.082*** 1.082*** 1.083***
    (10.95) (10.94) (10.95)
    Var7 1.016 1.016 1.016
    (1.06) (1.07) (1.07)
    Var8 0.918** 0.918** 0.918**
    (-2.85) (-2.84) (-2.85)
    N 20696 20696 20696
    Exponentiated coefficients; t statistics in parentheses * p < 0.05, ** p < 0.01, *** p < 0.001
    ----

    Could you, please, help me with following questions:

    1. What lns1_1_1_cons, lns1_1_2_cons and atr_1_1_1_2 from the table a) stand for and how to interpret them?

    2. Why they are not transfered to the MS Word table? Is it logically possible to transform them into odds ratios? And is it tehnically possible to export these odds ratios to a Word table?


    ----

    Thank you!
    Last edited by Mile Misic; 31 Oct 2018, 06:12.

  • #2
    This would be a lot easier to answer if you could show us the xtmelogit code and output.
    Richard T. Campbell
    Emeritus Professor of Biostatistics and Sociology
    University of Illinois at Chicago

    Comment


    • #3
      Originally posted by Dick Campbell View Post
      This would be a lot easier to answer if you could show us the xtmelogit code and output.
      Do you mean the code I am using?

      It is below. I've just changed names of variables into var1, var2, etc.

      Code:
      eststo clear
      eststo: xtmelogit dV var1 var2 var3 var4 var5 var6 var7 var 8 || groupidentifier:, or
      eststo: xtmelogit dV var1 var2 var3 var4 var5 var6 var7 var8 || groupidentifier: groupvar1, or cov(unstruct)
      eststo: xtmelogit dV var1 var2 var3 var4 var5 var6 var7 var8 || groupidentifier: groupvar2, or cov(unstruct)
      esttab, se wide transform(ln*: exp(@) exp(@))
      esttab, eform t, using MML_logit_1.rtf, replace
      Output is in tables in my first post.


      It might be that I don't understand what you are asking me to post, as I am first time here.

      Comment


      • #4
        Originally posted by Mile Misic View Post
        ...

        Output is in tables in my first post.


        It might be that I don't understand what you are asking me to post, as I am first time here.
        Actually, if you also copied the Stata output from your screen, it could help us show you what lns1_1_1_cons and all those strangely named parameters are. That said, all the lns_?_??_etc parameters are the random effect parameters, as Ben Jann (the author of esttab and all the related commands) documents on his website. More specifically, they are the logs of the standard deviations of the parameters.

        The one ending in e is the residual variance. Otherwise, I think the random effects parameters are numbered in the order that you saw them in your table. I am under the impression that in a 2-level model, the intercept is usually the last numbered parameter (but you must check this!!!).
        Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

        When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

        Comment


        • #5
          Originally posted by Weiwen Ng View Post

          Actually, if you also copied the Stata output from your screen, it could help us show you what lns1_1_1_cons and all those strangely named parameters are. That said, all the lns_?_??_etc parameters are the random effect parameters, as Ben Jann (the author of esttab and all the related commands) documents on his website. More specifically, they are the logs of the standard deviations of the parameters.

          The one ending in e is the residual variance. Otherwise, I think the random effects parameters are numbered in the order that you saw them in your table. I am under the impression that in a 2-level model, the intercept is usually the last numbered parameter (but you must check this!!!).
          Thank you a lot!

          Just for clarification, these are codes and output:

          1 dependent variable
          8 1st level variables
          2 2nd level variables



          Code:
          * Example generated by -dataex-. To install: ssc install dataex
          clear
          input float(makeid depvar indepvar1 indepvar2 indepvar3 indepvar9)
           2 0 10 4 1 20.4
           2 1  5 4 1 20.4
           2 1  5 3 1 20.4
           2 1  5 2 1 20.4
           2 0  4 3 1 20.4
           2 1  5 2 1 20.4
           8 0  7 1 1 60.7
           8 1  1 3 1 60.7
           8 0  5 3 1 60.7
           8 0 10 5 1 60.7
           8 0 10 5 1 60.7
          15 0  . 4 1 17.6
          15 1  . 3 1 17.6
          15 0  1 5 1 17.6
          15 1 10 4 1 17.6
          15 0  . 5 1 17.6
          15 0  8 5 1 17.6
          15 0  . 4 1 17.6
          15 0  . 5 1 17.6
          15 1  . 5 1 17.6
          10 1  5 3 1 24.9
          10 0  . 4 1 24.9
          10 1  3 4 1 24.9
          10 1  7 4 1 24.9
          10 1  3 2 1 24.9
          11 0  5 3 1 19.1
          11 0  . 4 1 19.1
          11 1  6 2 1 19.1
          11 1  6 1 1 19.1
          11 0 10 5 1 19.1
          11 0  6 1 1 19.1
          11 0  4 3 1 19.1
          11 1 10 4 1 19.1
          11 0  . 5 1 19.1
          11 1 10 1 1 19.1
          11 0  3 4 1 19.1
          11 0  3 1 1 19.1
          11 1  . . 1 19.1
          11 0  5 4 1 19.1
          11 1  5 4 1 19.1
          11 1  . 2 1 19.1
          11 1  . 4 1 19.1
          11 0  8 4 1 19.1
          11 1  8 2 1 19.1
          12 0  . 5 1  6.1
          12 0  8 3 1  6.1
          12 1 10 1 1  6.1
          12 1  5 3 1  6.1
          12 1 10 5 1  6.1
          12 0  2 5 1  6.1
          12 1  5 3 1  6.1
          12 1 10 3 1  6.1
          18 0 10 5 1 24.8
          18 0  . 3 1 24.8
          18 0  . 3 1 24.8
          18 1  1 3 1 24.8
          18 0  8 2 1 24.8
          18 0  . 4 1 24.8
          18 1  . 3 1 24.8
          18 1  5 2 1 24.8
          19 0  1 4 1 23.4
          19 1  8 5 1 23.4
          19 1  . 3 1 23.4
          19 1  . 3 1 23.4
          19 0  . . 1 23.4
          19 1 10 3 1 23.4
          19 1  1 5 1 23.4
          19 1  5 3 1 23.4
          21 1  1 2 1 23.5
          21 1  5 4 1 23.5
          21 0 10 5 1 23.5
          21 1  5 4 1 23.5
          21 0  . 3 1 23.5
          21 0  1 3 1 23.5
          21 1  . 3 1 23.5
          21 0  . 3 1 23.5
          21 1  . 3 1 23.5
          24 1  5 3 1 12.3
          24 1  6 1 1 12.3
          24 0  5 4 1 12.3
          24 0  7 5 1 12.3
          24 1  7 3 1 12.3
          24 1 10 3 1 12.3
          24 1  6 2 1 12.3
          24 1  7 5 1 12.3
          24 0  8 4 1 12.3
          24 0  8 3 1 12.3
          24 0 10 4 1 12.3
          24 1  8 4 1 12.3
          24 0  6 4 1 12.3
          24 0  9 4 1 12.3
           1 1  5 1 1 16.5
           1 0 10 4 1 16.5
           1 0  5 3 1 16.5
           1 0  1 2 1 16.5
           1 0  7 5 1 16.5
           1 0  2 2 1 16.5
           1 1  4 2 1 16.5
           1 0  5 4 1 16.5
           1 0  . 3 1 16.5
          end


          a) Without country-level variable

          Code:
          xtmelogit depvar indepvar1 indepvar2 indepvar3 indepvar4 indepvar5
          indepvar6 indepvar7 indepvar8  || groupid:, or
          Code:
          Mixed-effects logistic regression              Number of obs=20696
          Group variable: groupid                                        Number of groups=30
                                                                                        Obs per group: min = 183
                                                                                        avg =689.9 
                                                                                        max = 972
          
          Integration points =   7                              Wald chi2(8)       =    302.13
          Log likelihood = -13085.415                     Prob > chi2        =     0.0000
          
          -----------------------------------------------------------------------------------------------
            depvar  |         Odds Ratio  Std. Err.      z     P>|z|        [95% Conf. Interval]
          ------------------------------+----------------------------------------------------------------
            indepvar1  |   .8614803   .0163793    -7.84   0.000     .8299682    .8941888
            indepvar2  |   .9828163   .0257272    -0.66   0.508     .9336636    1.034557
            indepvar3  |   1.122266    .018314     7.07   0.000      1.08694      1.158741
            indepvar4  |   1.125427   .0264284     5.03   0.000     1.074803    1.178437
            indepvar5  |   .9961287   .0069067    -0.56   0.576     .9826835    1.009758
            indepvar6  |   1.082498   .0078379    10.95   0.000     1.067244    1.097969
            indepvar7  |   1.016258   .0154125     1.06   0.288     .9864946     1.04692
            indepvar8  |   .9179201   .0275784    -2.85   0.004     .8654281    .9735959
            _cons        |   .9097303   .1311024    -0.66   0.512     .6858749     1.206648
          -----------------------------------------------------------------------------------------------
          
          ------------------------------------------------------------------------------
            Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
          -----------------------------+------------------------------------------------
          groupid: Identity|
            sd(_cons) |            .3996772   .0544427     .3060283       .521984
          ------------------------------------------------------------------------------
          LR test vs. logistic regression: chibar2(01) =   596.87 Prob>=chibar2 = 0.0000

          With group-level variable 1:

          Code:
          xtmelogit depvar indepvar1 indepvar2 indepvar3 indepvar4 indepvar5 indepvar6 indepvar7
          indepvar8  || groupid: indepvar9,or cov(unstruct)

          Code:
          Mixed-effects logistic regression    Number of obs =20696
          Group variable: groupid                               Number of groups=30
          
                                                                              Obs per group: min=183
                                                                              avg=689.9
                                                                              max =972
          
          Integration points =   7                               Wald chi2(8)=302.90
          Log likelihood = -13084.096                      Prob > chi2=0.0000
          
          -----------------------------------------------------------------------------------------------
            depvar        | Odds Ratio   Std. Err.      z       P>|z|     [95% Conf. Interval]
          ------------------------------+----------------------------------------------------------------
             indepvar1    .8610052   .0163696    -7.87   0.000     .8295119    .8936943
             indepvar2    .9829303   .0257082    -0.66   0.510     .9338129    1.034631
             indepvar3     1.122449   .0183129    7.08   0.000     1.087124    1.158921
             indepvar4|   1.124847   .0263569     5.02   0.000     1.074357     1.17771
             indepvar5|   .9960515   .0069045    -0.57   0.568     .9826105    1.009676
             indepvar6 |  1.082393   .0078335    10.94   0.000     1.067148    1.097856
             indepvar7 |  1.016321   .0154107     1.07   0.286     .9865612    1.046979
             indepvar8 |  .9181373   .0275802    -2.84   0.004     .8656417    .9738165
             _cons |        .8383662   .1182917    -1.25   0.211     .6358153    1.105444
          -----------------------------------------------------------------------------------------------
          
          ------------------------------------------------------------------------------
          Random-effects Parameters     |   Estimate   Std. Err.        [95% Conf. Interval]
          -----------------------------+------------------------------------------------
          groupid: Unstructured |
                          sd(indepvar9) |             .0118611   .0047282      .0054302  .0259084
                          sd(_cons) |                   .4853906   .183767        .2311158    1.01942
                          corr(indepvar9,_cons) | -.8583496   .1692864     -.9878198 -.0265867
          ------------------------------------------------------------------------------
          LR test vs. logistic regression:     chi2(3) =   599.51   Prob > chi2 = 0.0000
          
          Note: LR test is conservative and provided only for reference.


          With group variable 2:

          Code:
          xtmelogit depvar indepvar1 indepvar2 indepvar3 indepvar4 indepvar5 indepvar6 indepvar7
          indepvar8  || groupid: indepvar10,or cov(unstruct)


          Code:
          Mixed-effects logistic regression|              Number of obs      =     20696
          Group variable: isocntrn|                           Number of groups   =        30
          
                                                                           Obs per group: min =       183
                                                                           avg =     689.9
                                                                           max =       972
          
          Integration points =   7                           Wald chi2(8)       =    302.14
          Log likelihood = -13085.283                   Prob > chi2        =    0.0000
          
          -----------------------------------------------------------------------------------------------
            depvar     | Odds Ratio   Std. Err.      z    P>|z|           [95% Conf. Interval]
          ------------------------------+----------------------------------------------------------------
           indepvar1 |   .8615591   .0163805    -7.84   0.000     .8300447    .8942701
           indepvar2 |   .9828957   .0257275    -0.66   0.510     .9337423     1.034637
           indepvar3 |   1.122279   .0183141     7.07   0.000      1.086952    1.158754
           indepvar4 |   1.124876   .0264261     5.01   0.000      1.074256    1.177882
           indepvar5 |   .9961247   .0069064    -0.56   0.575      .98268       1.009753
           indepvar6|   1.082538   .0078382    10.95   0.000      1.067284   1.09801
           indepvar7|   1.016319   .0154132     1.07   0.286      .9865546    1.046982
           indepvar8 |   .9178046   .0275758   -2.85   0.004     .8653175    .9734753
           _cons |        .9086213   .1308298    -0.67   0.506      .6852055    1.204883
          -----------------------------------------------------------------------------------------------
          
          ------------------------------------------------------------------------------
            Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
          -----------------------------+------------------------------------------------
          isocntrn: Unstructured
                        sd(indepvar10)              .003423     .00739      .0000497    .2355427
                        sd(_cons)                      .3377035   .1350672  .1542022    .7395718
                        corr(indepvar10,_cons) .9999968   .0114268      -1           1
          ------------------------------------------------------------------------------
          LR test vs. logistic regression:     chi2(3) =   597.13   Prob > chi2 = 0.0000
          
          Note: LR test is conservative and provided only for reference.

          Is there a way to export logs of standard deviation, together with odds ratios, to a MS Word table?

          Also, if I may, how to format Stata output when posting? I am using code delimiters, but tables are still not looking good. I was trying to adjust them manually, but it does not work.


          Thank you!

          Comment

          Working...
          X