Announcement

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

  • Using nlcom after postestimation margins

    Dear forum,

    Thanks in advance for any guidance you may give. I would like to estimate the ratio (95%CI) of two (2) predicted probabilities that were computed using postestimation margins after logistic regression. I thought I could use nlcom but I`m coming stuck.

    Code:
    logit dm i.sex 
    margins sex, post
    PHP Code:

    Logistic regression                                     Number of obs 
    =  4,830
                                                            LR chi2
    (1)    =   7.04
                                                            Prob 
    chi2   0.0080
    Log likelihood 
    = -2596.4629                             Pseudo R2     0.0014

    ------------------------------------------------------------------------------
              
    dm Coefficient  Stderr.      z    P>|z|     [95confinterval]
    -------------+----------------------------------------------------------------
             
    sex |
           
    Male  |  -.1912397   .0725017    -2.64   0.008    -.3333405    -.049139
           _cons 
    |   -1.14623   .0420583   -27.25   0.000    -1.228663   -1.063797
    ------------------------------------------------------------------------------ 
    .
    Code:
    margins sex, post
    PHP Code:

    Expression
    Pr(dm), predict()

    ------------------------------------------------------------------------------
                 |            
    Delta-method
                 
    |     Margin   stderr.      t    P>|t|     [95confinterval]
    -------------+----------------------------------------------------------------
             
    sex |
         
    Female  |      0.146      0.012    12.62   0.000        0.124       0.169
           Male  
    |      0.117      0.014     8.17   0.000        0.089       0.146
    ------------------------------------------------------------------------------ 

    Code:
    logit dm i.lclass

    PHP Code:
    Logistic regression                                     Number of obs =  3,338
                                                            LR chi2
    (4)    =  89.35
                                                            Prob 
    chi2   0.0000
    Log likelihood 
    = -1431.0752                             Pseudo R2     0.0303

    ------------------------------------------------------------------------------
              
    dm Coefficient  Stderr.      z    P>|z|     [95confinterval]
    -------------+----------------------------------------------------------------
          
    lclass |
              
    2  |   .1144973   .1324727     0.86   0.387    -.1451444     .374139
              3  
    |   1.012298    .181102     5.59   0.000     .6573448    1.367252
              4  
    |  -.6119494   .1525491    -4.01   0.000    -.9109402   -.3129587
              5  
    |   .3836895   .1778637     2.16   0.031     .0350831    .7322959
                 
    |
           
    _cons |  -1.662886   .1079938   -15.40   0.000     -1.87455   -1.451222
    ------------------------------------------------------------------------------ 
    Code:
    . margins lclass, post
    PHP Code:

    Expression
    Pr(dm), predict()

    ------------------------------------------------------------------------------
                 |            
    Delta-method
                 
    |     Margin   stderr.      t    P>|t|     [95confinterval]
    -------------+----------------------------------------------------------------
          
    lclass |
              
    1  |      0.078      0.023     3.47   0.001        0.034       0.123
              2  
    |      0.044      0.010     4.46   0.000        0.025       0.064
              3  
    |      0.213      0.052     4.08   0.000        0.111       0.316
              4  
    |      0.051      0.039     1.30   0.196       -0.026       0.128
              5  
    |      0.296      0.104     2.84   0.005        0.091       0.501
    ------------------------------------------------------------------------------ 
    Code:
     nlcom _b[Male.sex]\_b[1.lclass]
    PHP Code:
    [Male.sex]\_b[1.lclassnot found 


    Thanks,
    Itai

  • #2
    Try these in order:

    1) gen ratio = exp(_b[Male.sex] + _b[1.lclass]) / exp(_b[1.lclass])

    2) margins, at(Male.sex == 1 1.lclass == 1)

    3) margins, at(Male.sex == 0 1.lclass == 1)

    4) nlcom ratio_male_female: ratio / _b[/lnorm]

    Comment

    Working...
    X