Announcement

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

  • Transform or eform teffects ipw to odds and risk ratio

    Hi Everyone,

    First time Stata user and statistics imposter. I would like to exponentiate the results I have to an odds ratio, risk ratio and risk difference. See my code below, social housing is the binary exposure (treatment) and smoking after five years (binary) the outcome. I get "stuck" on the nlcom. Any advice would be much appreciated!!

    ***Analysis1(outcome model)(treatment model) average treatment effect in population
    teffects ipw (smoke_later) (socialhousing i.hgage hgsex i.inc_tert famtype i.hheduc householdsmok1), ate
    tebalance summarize
    tebalance overid, nolog

    **Analysis2(outcome model)(treatment model) estimate potential-outcome means
    teffects ipw (smoke_later) (socialhousing i.hgage hgsex i.inc_tert famtype i.hheduc householdsmok1), pomeans
    tebalance summarize
    nlcom log(_b[POmeans:1.socialhousing]/ _b[POmeans:0bn.socialhousing])
    Last edited by Erika Caramello; 24 Nov 2021, 18:34.

  • #2
    Below is an example estimating the effect of mother smoking at pregnancy (binary) on low birth weight of babies (binary). -nlcom- shows the estimate of odds ratio.

    Code:
    . webuse cattaneo2, clear
    (Excerpt from Cattaneo (2010) Journal of Econometrics 155: 138-154)
    
    . teffects ipw (lbweight) (mbsmoke mmarried c.mage##c.mage fbaby medu), pomeans
    
    Iteration 0:   EE criterion =  1.713e-21  
    Iteration 1:   EE criterion =  2.750e-33  
    
    Treatment-effects estimation                    Number of obs     =      4,642
    Estimator      : inverse-probability weights
    Outcome model  : weighted mean
    Treatment model: logit
    -------------------------------------------------------------------------------
                  |               Robust
         lbweight |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    --------------+----------------------------------------------------------------
    POmeans       |
          mbsmoke |
       nonsmoker  |   .0514829   .0037385    13.77   0.000     .0441556    .0588102
          smoker  |   .1030977   .0120102     8.58   0.000      .079558    .1266373
    -------------------------------------------------------------------------------
    
    . nlcom (_b[POmeans:1.mbsmoke]/(1-_b[POmeans:1.mbsmoke])) / (_b[POmeans:0.mbsmoke]/(1-_b
    > [POmeans:0.mbsmoke]))
    
           _nl_1:  (_b[POmeans:1.mbsmoke]/(1-_b[POmeans:1.mbsmoke])) / (_b[POmeans:0.mbsmoke
    > ]/(1-_b[POmeans:0.mbsmoke]))
    
    ------------------------------------------------------------------------------
        lbweight |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           _nl_1 |   2.117803   .3192954     6.63   0.000     1.491995     2.74361
    ------------------------------------------------------------------------------

    Comment


    • #3
      Thank you Fei Wang!

      So, if I were to exponentiate both the effect estimate and confidence interval to a risk ratio would I use the _nl_1 coef and CI? And if so, what would be the code for this? My colleague wants the risk difference; the risk ratio and the p-value for this model.

      Also, if I wanted to do the same model but with AIPW, would it be:

      teffects aipw (lbweight) (mbsmoke mmarried c.mage##c.mage fbaby medu), pomeans

      **and then same as above?
      nlcom (_b[POmeans:1.mbsmoke]/(1-_b[POmeans:1.mbsmoke])) / (_b[POmeans:0.mbsmoke]/(1-_b > [POmeans:0.mbsmoke])) _nl_1: (_b[POmeans:1.mbsmoke]/(1-_b[POmeans:1.mbsmoke])) / (_b[POmeans:0.mbsmoke > ]/(1-_b[POmeans:0.mbsmoke]))
      Thanks,
      Erika

      Comment


      • #4
        My colleague wants the risk difference; the risk ratio and the p-value for this model.
        For my example of #2, if the "risk difference" is the difference between "the probability of low birth weight with smoking mother" and "the probability of low birth weight with non-smoking mother", and the "risk ratio" is the ratio of the two, then code would be as below. I also list the code for odds ratio which remains the same when you use aipw. BTW, obtaining odds ratio by exponentiating original coefficients is for logit models. Your models are essentially linear probability models which have nothing to do with exponentiating.

        Code:
        webuse cattaneo2, clear
        teffects ipw (lbweight) (mbsmoke mmarried c.mage##c.mage fbaby medu), pomeans
        lincom _b[POmeans:1.mbsmoke] - _b[POmeans:0.mbsmoke]    // risk difference
        nlcom _b[POmeans:1.mbsmoke] / _b[POmeans:0.mbsmoke]        // risk ratio
        nlcom (_b[POmeans:1.mbsmoke]/(1-_b[POmeans:1.mbsmoke])) / (_b[POmeans:0.mbsmoke]/(1-_b[POmeans:0.mbsmoke]))    // odds ratio

        Comment


        • #5
          Thank you Fei Wang! I was hoping for one last bit of advice (and this is probably more domain specific knowledge which I should know but I am not a statistician ). I went to that meeting with the results from the above code - which worked, thank you! I was told that the "ATE" is the risk ratio (so first line of code below); and that I needed to exponentiate both the effect estimate and confidence intervals using the display exp(val) function where val is the value effect estimate? Is the effect estimate the coefficient of the ATE or ATET? Sorry for the heckling, I realise I am trying to build a bridge and I probably don't even know what the tools look like!

          1. teffects aipw (smoke_later) (socialhousing i.hgage hgsex i.inc_tert famtype i.hheduc householdsmok1), ate

          Comment


          • #6
            **So if I write:
            display exp(val1)
            display exp(val2)
            **where val is the ATE coefficient and val2 is the CI?

            Comment


            • #7
              ATE is a difference of two probabilities (risks) and it can't be a ratio. Sorry I'm not able to suggest more as I don't understand what exponentiating coefficients from a linear probability model attempts to obtain.

              Comment


              • #8
                The reason I query this is because the risk ratio is below 0? At .5904587. How would I transform this?

                Comment


                • #9
                  A linear probability model cannot guarantee the predicted probabilities to range between 0 and 1, so it's possible to have risk ratio and odds ratio out of range. For such models, we usually focus on ATE (i.e., risk difference). You may have to switch to a logit model for risk ratio and odds ratio if you obtain weird values of them from a linear probability model (as far as I know, there is no such "transformation" for linear probability model coefficients).

                  Comment


                  • #10
                    Your logic makes sense to me. Likely I completely misunderstood my colleague

                    Comment


                    • #11
                      Fei Wang is correct in #9 above but people have been working on this issue; in fact, there is a beta version of a program called "predict_ldm" devoted to this and info can be found at https://statisticalhorizons.com/bett...-probabilities

                      Comment


                      • #12
                        Thank you again for answering!

                        Comment

                        Working...
                        X