Announcement

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

  • Median Odds ratio calculate

    Good afternoon, I have a question, I need to calculate median odds ratio in stata (MOR). I saw your post and I do it. But I am not a statistics, and I have a question. If I have to calculate the MOR in a logistic regression multilevel in the coefficients. How can I do?. I don't have a variance.

    I do this: I don't Know what is the variance to calculate in the coefficients, PLEASE I NEED HELP


    . melogit mortalidad edad genero1 ipmTotal ZOMAC PDET afro indigena || codi
    > godivipoladepartamento: || id: , coeflegend

    Fitting fixed-effects model:

    Iteration 0: log likelihood = -889093.63
    Iteration 1: log likelihood = -518135.36
    Iteration 2: log likelihood = -503053.32
    Iteration 3: log likelihood = -502096.46
    Iteration 4: log likelihood = -502095.16
    Iteration 5: log likelihood = -502095.16

    Refining starting values:

    Grid node 0: log likelihood = -498130.58

    Fitting full model:

    Iteration 0: log likelihood = -498130.58 (not concave)
    Iteration 1: log likelihood = -498038.76 (not concave)
    Iteration 2: log likelihood = -498018.82 (not concave)
    Iteration 3: log likelihood = -497874.11 (not concave)
    Iteration 4: log likelihood = -497813.55 (not concave)
    Iteration 5: log likelihood = -497712.61
    Iteration 6: log likelihood = -497653.86
    Iteration 7: log likelihood = -497641.55
    Iteration 8: log likelihood = -497633.73
    Iteration 9: log likelihood = -497623.72
    Iteration 10: log likelihood = -497618.9
    Iteration 11: log likelihood = -497614.62
    Iteration 12: log likelihood = -497613.67
    Iteration 13: log likelihood = -497613.37
    Iteration 14: log likelihood = -497613.37

    Mixed-effects logistic regression Number of obs = 6313872

    -------------------------------------------------------------
    | No. of Observations per Group
    Group Variable | Groups Minimum Average Maximum
    ----------------+--------------------------------------------
    codigodivi~o | 36 1,953 175,385.3 1862553
    id | 1,120 1 5,637.4 1862553
    -------------------------------------------------------------

    Integration method: mvaghermite Integration pts. = 7

    Wald chi2(7) = 253629.68
    Log likelihood = -497613.37 Prob > chi2 = 0.0000
    ------------------------------------------------------------------------------
    mortalidad | Coef. Legend
    -------------+----------------------------------------------------------------
    edad | .0887654 _b[edad]
    genero1 | .6754843 _b[genero1]

    _cons | -9.571593 _b[_cons]
    -------------+----------------------------------------------------------------
    codigodivi~o |
    var(_cons)| .039265 _b[/var(_cons[codigodivipoladepartamento])]
    -------------+----------------------------------------------------------------
    codigodivi~o>|
    id |
    var(_cons)| .1093776 _b[/var(_cons[codigodivipoladepartamento>id])]
    ------------------------------------------------------------------------------
    LR test vs. logistic model: chi2(2) = 8963.58 Prob > chi2 = 0.0000

    Note: LR test is conservative and provided only for reference.

    .


    . nlcom exp(sqrt(2*_b[edad])*invnormal(0.75)), cformat(%9.2f)

    _nl_1: exp(sqrt(2*_b[edad])*invnormal(0.75))

    ------------------------------------------------------------------------------
    mortalidad | Coef. Std. Err. z P>|z| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    _nl_1 | 1.33 0.00 3499.28 0.000 1.33 1.33
    ------------------------------------------------------------------------------

    . nlcom exp(sqrt(2*_b[genero1])*invnormal(0.75)), cformat(%9.2f)

    _nl_1: exp(sqrt(2*_b[genero1])*invnormal(0.75))

    ------------------------------------------------------------------------------
    mortalidad | Coef. Std. Err. z P>|z| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    _nl_1 | 2.19 0.01 294.11 0.000 2.18 2.20
    ------------------------------------------------------------------------------

  • #2
    The easiest way will be to install xtmrho from SSC and estimate the model using xtmelogit instead of melogit. Running this command after xtmelogit will directly give you the median odds ratios. You could calculate the statistics by hand, but it is just a hassle.

    Code:
    ssc install xtmrho, replace
    Code:
    use http://www.stata-press.com/data/r9/productivity.dta, clear
    gen gsp_l9 = gsp<9
    xtmelogit gsp_l9 private emp hwy water other unemp ||  region: ||  state:, nolog
    xtmrho
    Res.:

    Code:
    . xtmelogit gsp_l9 private emp hwy water other unemp ||  region: ||  state:, nolog
    
    Mixed-effects logistic regression               Number of obs     =        816
    
    ----------------------------------------------------------------------------
                    |     No. of       Observations per Group       Integration
     Group Variable |     Groups    Minimum    Average    Maximum      Points
    ----------------+-----------------------------------------------------------
             region |          9         51       90.7        136           7
              state |         48         17       17.0         17           7
    ----------------------------------------------------------------------------
    
                                                    Wald chi2(6)      =      14.00
    Log likelihood = -32.974673                     Prob > chi2       =     0.0296
    
    ------------------------------------------------------------------------------
          gsp_l9 | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
         private |   -11.3643   4.893172    -2.32   0.020    -20.95474   -1.773857
             emp |  -18.53072   6.736886    -2.75   0.006    -31.73478   -5.326666
             hwy |    .628602   7.547234     0.08   0.934    -14.16371    15.42091
           water |  -3.278833   3.180811    -1.03   0.303    -9.513108    2.955443
           other |  -.3236346   3.764555    -0.09   0.931    -7.702026    7.054757
           unemp |   .4212584   .3778835     1.11   0.265    -.3193796    1.161896
           _cons |   219.9495   75.27173     2.92   0.003     72.41963    367.4794
    ------------------------------------------------------------------------------
    
    ------------------------------------------------------------------------------
      Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
    -----------------------------+------------------------------------------------
    region: Identity             |
                       sd(_cons) |   2.76e-09   1.350559             0           .
    -----------------------------+------------------------------------------------
    state: Identity              |
                       sd(_cons) |   2.888043   1.287396      1.205495    6.918973
    ------------------------------------------------------------------------------
    LR test vs. logistic model: chi2(2) = 12.58               Prob > chi2 = 0.0019
    
    Note: LR test is conservative and provided only for reference.
    
    . 
    . xtmrho
    
    Levels: region state
    
    level 1:
    Intraclass correlation  (ICC):  rho1 = 0.00000
    Median Odds Ratio (MOR):        mor1 = 1.00000
    
    level 2:
    Intraclass correlation  (ICC):  rho2 = 0.71714
    Median Odds Ratio (MOR):        mor2 = 15.71828

    Comment

    Working...
    X