Announcement

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

  • generating an absolute risk ratio

    Hello I would like to generate an absolute risk ratio and NNT

    I've been told to manually calculate it, however I just wanted to be sure if stata can generate the absolute risk ratio following:

    Code:
    Logit var1 var2 var3 [pw=weight], or
    I found this:
    Computing Adjusted Risk Ratios and Risk Differences in Stata (sagepub.com)

    However, this creates an adjusted risk ratio. Can stata calculate the absolute risk ratio following a logit ?

  • #2
    What is an absolute risk ratio? Risk ratios are relative, did you mean an (absolute) risk difference? I assume that you want the risk difference

    The code you show computes odds ratios, not risk ratios, so that's off the mark for both.

    The article you linked has fine information as background. A canonical way to do this is to use -margins-, either after plain -logit-, or more commonly, -poisson- with robust standard errors. Here's a sketch of code using the poisson model assuming that you have a single treatment group coded as 0 (no treatment or control) and 1 (treatment).

    Code:
    poisson outcome i.treatment, vce(robust) eform
    lincom 1.treatment, eform  // this gives the RR for treatment compared to control
    margins , dydx(treatment)  // this will give you the absolute risk difference between treatment groups
    From here you can work out the NNT....but my recommendation is that you only do this if the RR is significantly difference from the null of RR=1 (no effect) since otherwise the associated confidence interval will not be meaningful.

    Comment


    • #3
      Thank you so much for this.

      hm If I was using -logit- to generate an odds ratio to see if the new treatment was more likely to have a complication eg an infection compared to the old treatment.

      with a poisson , this would be looking at counts/ rates rather than the proportions as in an odds ratio.

      i can still present a RR which actually is more relatable.
      However, I always thought that poisson was used for counts, although now I see I can also use poisson to reflect the same findings

      what are your thoughts on this?

      Comment


      • #4
        Often odds ratios are used as a substitute for risk ratios, especially when they can’t be calculated directly, due to the study design, for example.

        If you’re working with a clinical trial dataset, which it seems like you might be, then you can compute the risk ratio directly which is more intuitive and direct for comparing relative risk of a treatment then the odds ratio. Odds ratios should generally agree in direction and substantive conclusions with the risk ratio for treatment. However, odds ratios will always be more exaggerated.

        Since you want to also calculate the risk difference, it seems natural to use the same model to compute the RR and RD. But, it’s not the only way. A logistic regression model can be used to generate the same marginal prediction which will be interpretable as a risk difference. The two models should generally yield similar results.

        As for poisson regression models, they are often taught in the context of modeling counts, but they do work more generally for proportions and means of any kind as long as the expected value is not negative. Do be sure to use robust variance estimates with such a model when the outcome is binary to get correct standard errors.

        Comment


        • #5
          Thanks for this. I hope you had a great Christmas.

          With regards to Post 2
          I think you meant this:

          Code:
          poisson outcome i.treatment, vce(robust)
          
          ///I.e without the EFORM. As if one adds the eform as your line1 in your code, Stata returns the error -option eform not allowed-
          Also with regards to your Post 4

          You say:
          Since you want to also calculate the risk difference, it seems natural to use the same model to compute the RR and RD. But, it’s not the only way. A logistic regression model can be used to generate the same marginal prediction which will be interpretable as a risk difference. The two models should generally yield similar results.


          Why do you say a logistic regression can be used to generate the same marginal prediction? margins will generate probabilities. How can these be interpreted as risk difference? Or are you saying the results for margins following logit should be the same as the risk differences from a passion as shown in line3 of your code in Post .

          AS from what I can understand, if I have used a logit model, then essentially I need to convert to poisson to generate Risk ratios.

          Also are there any reading references with regards to use of lincom, margins following poisson please?
          Last edited by Denise Vella; 27 Dec 2023, 14:23.

          Comment


          • #6
            Originally posted by Denise Vella View Post
            Thanks for this. I hope you had a great Christmas.

            With regards to Post 2
            I think you meant this:

            Code:
            poisson outcome i.treatment, vce(robust)
            
            ///I.e without the EFORM. As if one adds the eform as your line1 in your code, Stata returns the error -option eform not allowed-
            Sorry, instead of -eform- which is a generic request of some estimation commands to produce exponentiated coeffcients, -poisson- requires -irr- which does the same thing.


            Also with regards to your Post 4

            You say:
            Since you want to also calculate the risk difference, it seems natural to use the same model to compute the RR and RD. But, it’s not the only way. A logistic regression model can be used to generate the same marginal prediction which will be interpretable as a risk difference. The two models should generally yield similar results.


            Why do you say a logistic regression can be used to generate the same marginal prediction? margins will generate probabilities. How can these be interpreted as risk difference? Or are you saying the results for margins following logit should be the same as the risk differences from a passion as shown in line3 of your code in Post .

            AS from what I can understand, if I have used a logit model, then essentially I need to convert to poisson to generate Risk ratios.
            Let's assume you use a logistic regression model. There are two treatment groups (0 and 1) and two possible outcomes (also 0 and 1). This is the most basic structure for a 2-arm parallel trial.

            You can estimate the difference between the average (marginal) probabilities for each treatment group by doing something like the following.

            Code:
            logit outcome i.treatment, or
            margins i.treatment   // estimate marginal mean probability of each treatment group
            margins , dydx(treatment)  // estimate of risk difference - the difference of those two treatment group marginal mean probabilities
            An analogous way to do this with the poisson model follows a very similar template.

            Code:
            poisson outcome i.treatment, irr vce(robust)
            margins i.treatment
            margins , dydx(treatment) // risk difference estimate
            In practice these marginal estimates and their differences will be similar between models with reasonable sample sizes. Both models can be used to get the risk differences, with the logit indirectly modeling the odds of he outcome, and the poisson regression directly modeling risk.


            Also are there any reading references with regards to use of lincom, margins following poisson please?
            You can read more about each of those commands in general by -help lincom- and -help margins-, etc. Both of these are quite general commands and so will not exclusively discuss their use with poisson regression. You can also read about poisson postestimation specifically using -help poisson post-estimation-.

            Comment


            • #7
              I was just testing with some dummy data using this database. Thanks for helping out. However, I still have some questions if you
              do have time to address these queries.

              Firstly, Stata help refers to the IRR - as the INCIDENCE RATE RATIOS. The interpretation is the same as the Risk ratio.
              However, I am not sure with regards to the calculations in the background if they can be used synonymously. Therefore considering
              INCIDENCE RATE RATIO = RISK RATIOS ?

              Secondly, the results from Section 1 and Section 2 are the same. So why bother with Section 2? (see below)

              Code:
              //check odds ratios
              
              clear all
              use https://www.pclambert.net/data/rott2b, clear
              logit pr_1 hormon, or 
              
              //OR: 0.72
              
              //Generating risk ratios = relative risk ANDA absolture Risk 
              
              //Section 1
              //Incidence rate ratio
              poisson pr_1 i.hormon, irr vce(robust) //shows that hormonlal treatment at 0.833 times more likely to have pr_1
              
              
              //Section 2
              lincom 1.hormon, eform  // this gives the RR for treatment compared to control //same results as above
              
              margins , dydx(hormon)  // this will give you the absolute risk difference between treatment groups
              
              //Interpreation: that those with hormonal treatment are -0.5 less likely to have a pr_1 receptor

              Comment


              • #8
                Exponentiated coefficients from a Poisson model are referred to as incidence rate ratios (IRR), rate ratios (RR) or risk ratios (RR). These are just names, but the underlying math is the same, for a one unit change in the predictor variable, the difference in the logs of expected counts is expected to change by the respective regression coefficient, given the other predictor variables in the model are held constant

                It may be that depending on the variables in your model, one name may better suit the descriptive interpretation of the quantity (for example, using an offset may better suit an interpretation as IRR).

                In section 2, the lincom simply reports the coefficient from the model, so it's not necessary to get the RR. You could read this off of the regression model table. The -margins- statement though is not redundant.

                That said, your example is not correct if you wish to compute risk differences or NNT. The reason being is that risk differences (and NNT) can only be understood if the outcome is binary, or equivalently, risk is expressed as an incidence proportion. The example above is a logged concentration value. Here's a simple example using that same dataset.

                Code:
                clear all
                use https://www.pclambert.net/data/rott2b, clear
                
                // logit model
                logit rfi i.hormon, or nolog
                margins i.hormon
                margins, dydx(hormon)
                
                // poisson model
                poisson rfi i.hormon, nolog irr vce(robust)
                margins i.hormon
                margins, dydx(hormon)
                result

                Code:
                . // logit model
                . logit rfi i.hormon, or nolog
                
                Logistic regression                                     Number of obs =  2,982
                                                                        LR chi2(1)    =   1.19
                                                                        Prob > chi2   = 0.2762
                Log likelihood = -2065.8831                             Pseudo R2     = 0.0003
                
                ------------------------------------------------------------------------------
                         rfi | Odds ratio   Std. err.      z    P>|z|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                      hormon |
                        yes  |   1.134073   .1311684     1.09   0.277     .9040444     1.42263
                       _cons |   1.022188   .0397684     0.56   0.573     .9471412    1.103182
                ------------------------------------------------------------------------------
                Note: _cons estimates baseline odds.
                
                . margins i.hormon
                
                Adjusted predictions                                     Number of obs = 2,982
                Model VCE: OIM
                
                Expression: Pr(rfi), predict()
                
                ------------------------------------------------------------------------------
                             |            Delta-method
                             |     Margin   std. err.      z    P>|z|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                      hormon |
                         no  |   .5054862   .0097251    51.98   0.000     .4864253    .5245471
                        yes  |   .5368732   .0270823    19.82   0.000     .4837928    .5899535
                ------------------------------------------------------------------------------
                
                . margins, dydx(hormon)
                
                Conditional marginal effects                             Number of obs = 2,982
                Model VCE: OIM
                
                Expression: Pr(rfi), predict()
                dy/dx wrt:  1.hormon
                
                ------------------------------------------------------------------------------
                             |            Delta-method
                             |      dy/dx   std. err.      z    P>|z|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                      hormon |
                        yes  |    .031387   .0287755     1.09   0.275     -.025012    .0877859
                ------------------------------------------------------------------------------
                Note: dy/dx for factor levels is the discrete change from the base level.
                
                .
                . // poisson model
                . poisson rfi i.hormon, nolog irr vce(robust)
                
                Poisson regression                                      Number of obs =  2,982
                                                                        Wald chi2(1)  =   1.24
                                                                        Prob > chi2   = 0.2646
                Log pseudolikelihood = -2542.6682                       Pseudo R2     = 0.0001
                
                ------------------------------------------------------------------------------
                             |               Robust
                         rfi |        IRR   std. err.      z    P>|z|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                      hormon |
                        yes  |   1.062093   .0573508     1.12   0.265     .9554309    1.180662
                       _cons |   .5054862   .0097268   -35.45   0.000     .4867771    .5249143
                ------------------------------------------------------------------------------
                Note: _cons estimates baseline incidence rate.
                
                . margins i.hormon
                
                Adjusted predictions                                     Number of obs = 2,982
                Model VCE: Robust
                
                Expression: Predicted number of events, predict()
                
                ------------------------------------------------------------------------------
                             |            Delta-method
                             |     Margin   std. err.      z    P>|z|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                      hormon |
                         no  |   .5054862   .0097268    51.97   0.000     .4864221    .5245503
                        yes  |   .5368732   .0270869    19.82   0.000     .4837839    .5899624
                ------------------------------------------------------------------------------
                
                . margins, dydx(hormon)
                
                Conditional marginal effects                             Number of obs = 2,982
                Model VCE: Robust
                
                Expression: Predicted number of events, predict()
                dy/dx wrt:  1.hormon
                
                ------------------------------------------------------------------------------
                             |            Delta-method
                             |      dy/dx   std. err.      z    P>|z|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                      hormon |
                        yes  |    .031387   .0287803     1.09   0.275    -.0250215    .0877954
                ------------------------------------------------------------------------------
                Note: dy/dx for factor levels is the discrete change from the base level.
                Notice marginal estimates are the same with very similar standard errors. The interpretation of the RD is that those with hormone treatment have about a 3.2 percentage points greater risk of being relapse-free compared to those without the treatment.

                Comment


                • #9
                  Thanks, that's a great explanation. Happy new year!

                  To clarify, with regards to the interpretation from


                  Code:
                  margins i.hormon 
                  ///following poisson
                  This would mean:
                  Those on hormonal treatment (yes) are 54 percentage points more likely to relapse compared to those not on hormonal treatment (50 percentage points)

                  Is this correct?

                  Comment


                  • #10
                    Hello Denise Vella & Leonardo Guizzetti. Let me add that -binreg- is another way to get the risk difference. Here is a modified version of Leonardo's example in #8.

                    Cheers,
                    Bruce

                    Code:
                    Code:
                    cls
                    clear all
                    use https://www.pclambert.net/data/rott2b
                    
                    // Use -binreg- to get the RD
                    binreg rfi i.hormon, rd
                    margins i.hormon // show the two absolute risks
                    margins, dydx(hormon) // show the risk difference
                    margins ar.(hormon) // another way to get the risk difference
                    Output:
                    Code:
                    . clear all
                    
                    . use https://www.pclambert.net/data/rott2b
                    (Rotterdam breast cancer data (augmented with cause of death))
                    
                    .
                    . // Use -binreg- to get the RD
                    . binreg rfi i.hormon, rd
                    
                    Iteration 1:  Deviance =  4131.766
                    Iteration 2:  Deviance =  4131.766
                    
                    Generalized linear models                         Number of obs   =      2,982
                    Optimization     : MQL Fisher scoring             Residual df     =      2,980
                                       (IRLS EIM)                     Scale parameter =          1
                    Deviance         =  4131.766247                   (1/df) Deviance =   1.386499
                    Pearson          =         2982                   (1/df) Pearson  =   1.000671
                    
                    Variance function: V(u) = u*(1-u)                 [Bernoulli]
                    Link function    : g(u) = u                       [Identity]
                    
                                                                      BIC             =  -19709.28
                    
                    ------------------------------------------------------------------------------
                                 |                 EIM
                             rfi | Risk diff.   std. err.      z    P>|z|     [95% conf. interval]
                    -------------+----------------------------------------------------------------
                          hormon |
                            yes  |    .031387   .0287755     1.09   0.275     -.025012    .0877859
                           _cons |   .5054862   .0097251    51.98   0.000     .4864253    .5245471
                    ------------------------------------------------------------------------------
                    
                    . margins i.hormon // show the two absolute risks
                    
                    Adjusted predictions                                     Number of obs = 2,982
                    Model VCE: EIM
                    
                    Expression: Predicted mean rfi, predict()
                    
                    ------------------------------------------------------------------------------
                                 |            Delta-method
                                 |     Margin   std. err.      z    P>|z|     [95% conf. interval]
                    -------------+----------------------------------------------------------------
                          hormon |
                             no  |   .5054862   .0097251    51.98   0.000     .4864253    .5245471
                            yes  |   .5368732   .0270823    19.82   0.000     .4837928    .5899535
                    ------------------------------------------------------------------------------
                    
                    . margins, dydx(hormon) // show the risk difference
                    
                    Conditional marginal effects                             Number of obs = 2,982
                    Model VCE: EIM
                    
                    Expression: Predicted mean rfi, predict()
                    dy/dx wrt:  1.hormon
                    
                    ------------------------------------------------------------------------------
                                 |            Delta-method
                                 |      dy/dx   std. err.      z    P>|z|     [95% conf. interval]
                    -------------+----------------------------------------------------------------
                          hormon |
                            yes  |    .031387   .0287755     1.09   0.275     -.025012    .0877859
                    ------------------------------------------------------------------------------
                    Note: dy/dx for factor levels is the discrete change from the base level.
                    
                    . margins ar.(hormon) // another way to get the risk difference
                    
                    Contrasts of adjusted predictions                        Number of obs = 2,982
                    Model VCE: EIM
                    
                    Expression: Predicted mean rfi, predict()
                    
                    ------------------------------------------------
                                 |         df        chi2     P>chi2
                    -------------+----------------------------------
                          hormon |          1        1.19     0.2754
                    ------------------------------------------------
                    
                    --------------------------------------------------------------
                                 |            Delta-method
                                 |   Contrast   std. err.     [95% conf. interval]
                    -------------+------------------------------------------------
                          hormon |
                    (yes vs no)  |    .031387   .0287755      -.025012    .0877859
                    --------------------------------------------------------------
                    --
                    Bruce Weaver
                    Email: [email protected]
                    Version: Stata/MP 18.5 (Windows)

                    Comment


                    • #11
                      No. The interpretation of the marginal probabilities are those of probabilities. So the risk of no relapse in the treated group is 53.7%. When discussing absolute differences of proportions, the correct unit is not percent (%), but rather percentage points.

                      Comment


                      • #12
                        Indeed, Bruce Weaver is right about another alternative estimation method. There are around 10 or so methods in total but these are probably among the most common.

                        Comment


                        • #13
                          Dear Leonardo,
                          Thank you for being so patient. Yes I have now realised there are several options.
                          However I would like to clarify your Post 11 and my question in Post 9 clarifying the interpretation.


                          You say
                          So the risk of no relapse in the treated group is 53.7%.

                          However, if rfi is a binary variable 0 - no relapse 1- relapse

                          Would it not be:
                          Risk of relapse for those in the treated group (yes hormonal) 53.7%
                          Risk of relapse for those in the untreated group (no hormonal) 50.5%

                          And with regards to absolute risk difference this would be interpreted as:
                          For those in the treated group vs untreated group, the absolute risk difference in relapse is 0.03 percentage points.

                          I am so sorry to bother you again with this. I just wanted to reclarify.



                          Click image for larger version

Name:	Screenshot 2023-12-28 at 19.25.47.png
Views:	1
Size:	230.1 KB
ID:	1738367

                          Comment


                          • #14
                            Originally posted by Denise Vella View Post
                            You say
                            So the risk of no relapse in the treated group is 53.7%.

                            However, if rfi is a binary variable 0 - no relapse 1- relapse

                            Would it not be:
                            Risk of relapse for those in the treated group (yes hormonal) 53.7%
                            Risk of relapse for those in the untreated group (no hormonal) 50.5%
                            The variable name, rfi, and its description are little ambiguous in that dataset as to what 0 and 1 represent. I took it to mean that when rfi=1, there is no relapse (since rfi would seem to stand for relapse-free indicator). I am referring to whatever rfi=1 is as the outcome in my interpretation. Your interpretation is correct if rfi=1 is referring to relapse.

                            And with regards to absolute risk difference this would be interpreted as:
                            For those in the treated group vs untreated group, the absolute risk difference in relapse is 0.03 percentage points.
                            The absolute risk difference in the treated group is 3.1 percentage points higher (= 53.7% - 50.5%) than in the control group. Do not divide it by 100, it's not a percentage.

                            Comment

                            Working...
                            X