Announcement

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

  • New commands for the estimation of marginal odds ratios (+ working paper)

    Three new commands for the estimation of marginal odds ratios are available from SSC. To install the commands, type:

    Code:
    . ssc install lnmor
    . ssc install ipwlogit
    . ssc install riflogit
    . ssc install moremata // required by lnmor
    The details of the different estimation approaches are discussed in:

    Jann, B., K.B. Karlson. 2023. Estimation of marginal odds ratios. University of Bern Social Sciences Working Papers 44. https://ideas.repec.org/p/bss/wpaper/44.html

    ben

  • #2
    Interesting stuff!
    I notice that your working paper does not mention the "official" Stata commands margins or teffects ipw, which (as I understand it) implement g-computation and IPW respectively. To help my understanding of all this, would it be possible to summarize where these new commands deviate from the functionality of the existing official commands?
    Many thanks, and best wishes,
    David.

    Comment


    • #3
      Hi David, indeed lnmor is closely related to margins, ipwlogit has relations to teffects ipw. In case of a binary treatment, margins followed by nlcom can be used to compute marginal odds ratios as obtained by lnmor; and teffects ipw followed by nlcom can be used to compute results as obtained by ipwlogit. Examples:

      Code:
      . webuse lbw
      (Hosmer & Lemeshow data)
      
      . logit low i.smoke i.race age lwt ptl ht ui, vce(robust)
      
      (output omitted)
      
      . lnmor i.smoke, or
      
      Enumerating predictions: smoke..done
      
      Marginal odds ratio                             Number of obs     =        189
                                                      Command           =      logit
      
      ------------------------------------------------------------------------------
                   |               Robust
               low | Odds Ratio   std. err.      t    P>|t|     [95% conf. interval]
      -------------+----------------------------------------------------------------
             smoke |
           Smoker  |   2.188234   .7145092     2.40   0.017     1.149095    4.167077
      ------------------------------------------------------------------------------
      
      . margins, at(smoke=(0 1)) post vce(unconditional)
      
      (output omitted)
      
      . nlcom (smoke:(logit(_b[2._at]) - logit(_b[1._at]))), post
      
      (output omitted)
      
      . ereturn display, eform(Odds Ratio)
      ------------------------------------------------------------------------------
                   | Odds Ratio   Std. err.      z    P>|z|     [95% conf. interval]
      -------------+----------------------------------------------------------------
             smoke |   2.188234   .7145092     2.40   0.016     1.153869    4.149835
      ------------------------------------------------------------------------------
      Code:
      . ipwlogit low i.smoke i.race age lwt ptl ht ui, nolog or
      (estimating balancing weights ... done)
      
      Marginal logistic regression                    Number of obs     =        189
                                                      Wald chi2(1)      =       2.21
                                                      Prob > chi2       =     0.1371
                                                      Pseudo R2         =     0.0114
                                                      Treatment type    =     factor
                                                      Number of levels  =          2
                                                      PS method         =      logit
      
      ------------------------------------------------------------------------------
                   |               Robust
               low | Odds Ratio   std. err.      z    P>|z|     [95% conf. interval]
      -------------+----------------------------------------------------------------
             smoke |
           Smoker  |   1.687593   .5940917     1.49   0.137     .8464765    3.364499
             _cons |   .3022335    .067613    -5.35   0.000     .1949482    .4685608
      ------------------------------------------------------------------------------
      (adjusted for i.race age lwt ptl ht ui)
      
      Distribution of IPWs
             level          N       mean        sum        min        max         cv
         Nonsmoker        115   1.003055   115.3513    .652079    7.19102   .6333993
            Smoker         74     1.0806   79.96439   .4042393   8.085316   1.018199
      
      . teffects ipw (low) (smoke i.race age lwt ptl ht ui), pomeans
      
      (output omitted)
      
      . nlcom (smoke: logit(_b[1.smoke]) - logit(_b[0.smoke])), post
      
      (output omitted)
      
      . ereturn display, eform(Odds Ratio)
      ------------------------------------------------------------------------------
               low | Odds Ratio   Std. err.      z    P>|z|     [95% conf. interval]
      -------------+----------------------------------------------------------------
             smoke |   1.687593    .592518     1.49   0.136     .8480251    3.358355
      ------------------------------------------------------------------------------
      
      . di %9.0g r(table)[2,1] * sqrt(e(N)/(e(N)-1))
       .5940917
      So in these situations lnmor and ipwlogit just provide additional convenience. The USP of lnmor and ipwlogit is that they support continuous treatments.

      ben

      Comment


      • #4
        We now also put together a non-technical paper on marginal odds ratios:

        Karlson, K.B., B. Jann. 2023. Marginal Odds Ratios: What They Are, How to Compute Them, and Why Sociologists Might Want to Use Them. University of Bern Social Sciences Working Papers 45. https://ideas.repec.org/p/bss/wpaper/45.html

        ben

        Comment


        • #5
          Dear Ben Jann. Thanks for sharing lnmor and the non-technical working paper. Do you have any suggestions on how to use coefplot to show lnmor results?

          Comment


          • #6
            Originally posted by Ben Jann View Post
            Three new commands for the estimation of marginal odds ratios are available from SSC. To install the commands, type:

            Code:
            . ssc install lnmor
            . ssc install ipwlogit
            . ssc install riflogit
            . ssc install moremata // required by lnmor
            The details of the different estimation approaches are discussed in:

            Jann, B., K.B. Karlson. 2023. Estimation of marginal odds ratios. University of Bern Social Sciences Working Papers 44. https://ideas.repec.org/p/bss/wpaper/44.html

            ben
            Thank you, Ben!

            Comment

            Working...
            X