Announcement

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

  • how to report Odds ratio for interactions terms separately for male and female in binary logistic regression

    Dear Statalist

    I ran logistic regression on an AMI (acute myocardial infarction) dataset of 9 variables using Stata version 14.2. Following is the multivariable adjusted model, query is mentioned right below the table.

    logistic mortality i.Gender age_10 ib(2).AMI_type ib(0).Diabetes ib(0).dyslipidemia_1 ib(0).Hypertension Discharge_Year ib(0).PTCAPCI c.age_10#Gender b(2).AMI_type#Gender

    Logistic regression Number of obs = 11,673
    LR chi2(10) = 672.86
    Prob > chi2 = 0.0000
    Log likelihood = -3355.4983 Pseudo R2 = 0.0911


    mortality Odds Ratio Std. Err. z P>z [95% Conf. Interval]

    Gender
    Female 3.306906 1.418547 2.79 0.005 1.426547 7.665802
    age_10 1.591416 .0581228 12.72 0.000 1.481479 1.709511

    AMI_type
    STEMI 2.462539 .2253916 9.85 0.000 2.058137 2.946402

    Diabetes
    Yes 1.258716 .0857974 3.38 0.001 1.101305 1.438626

    dyslipidemia_1
    Yes .3368114 .0333947 -10.98 0.000 .2773259 .4090564

    Hypertension
    Yes .9556454 .0715644 -0.61 0.545 .8251896 1.106725
    Discharge_Year .9769054 .0059796 -3.82 0.000 .9652556 .9886958

    PTCAPCI
    Yes .4894141 .0390456 -8.96 0.000 .4185694 .5722497

    Gender#c.age_10
    Female .842007 .0506165 -2.86 0.004 .748422 .9472942

    AMI_type#Gender
    STEMI#Female 1.393794 .1925035 2.40 0.016 1.063249 1.827099

    _cons 1.12e+18 1.38e+19 3.38 0.001 3.91e+07 3.21e+28


    Can someone please guide how can I obtain the Odds ratio for interaction terms separately for Male and Female. Its a very important query I am unable to find answer for my supervisor at work really wants me to find answer for this please can someone help. Thanks in advance





  • #2
    lincom would probablt be the easiest option. Alternatively, you could consider https://www.stata-journal.com/articl...article=st0250
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      1) generate "female" binary variable taking value of 1 if F and 0 if M.
      2) generate "male" binary variable taking value of 1 if M and 0 if M.
      1.1.) generate interaction term as femala_age=female*age_10 (do it for males as well if you wish )
      2.1) generate interaction term as female_ami=female*AMI_type (do it for males as well if you wish)

      In your regression model,


      logistic mortality i.male i.female female_age (male_age) female_ami (male_ami) x3 x4 x5.....

      then compute the marginal effects.


      Originally posted by anam ali View Post
      Dear Statalist

      I ran logistic regression on an AMI (acute myocardial infarction) dataset of 9 variables using Stata version 14.2. Following is the multivariable adjusted model, query is mentioned right below the table.

      logistic mortality i.Gender age_10 ib(2).AMI_type ib(0).Diabetes ib(0).dyslipidemia_1 ib(0).Hypertension Discharge_Year ib(0).PTCAPCI c.age_10#Gender b(2).AMI_type#Gender

      Logistic regression Number of obs = 11,673
      LR chi2(10) = 672.86
      Prob > chi2 = 0.0000
      Log likelihood = -3355.4983 Pseudo R2 = 0.0911


      mortality Odds Ratio Std. Err. z P>z [95% Conf. Interval]

      Gender
      Female 3.306906 1.418547 2.79 0.005 1.426547 7.665802
      age_10 1.591416 .0581228 12.72 0.000 1.481479 1.709511

      AMI_type
      STEMI 2.462539 .2253916 9.85 0.000 2.058137 2.946402

      Diabetes
      Yes 1.258716 .0857974 3.38 0.001 1.101305 1.438626

      dyslipidemia_1
      Yes .3368114 .0333947 -10.98 0.000 .2773259 .4090564

      Hypertension
      Yes .9556454 .0715644 -0.61 0.545 .8251896 1.106725
      Discharge_Year .9769054 .0059796 -3.82 0.000 .9652556 .9886958

      PTCAPCI
      Yes .4894141 .0390456 -8.96 0.000 .4185694 .5722497

      Gender#c.age_10
      Female .842007 .0506165 -2.86 0.004 .748422 .9472942

      AMI_type#Gender
      STEMI#Female 1.393794 .1925035 2.40 0.016 1.063249 1.827099

      _cons 1.12e+18 1.38e+19 3.38 0.001 3.91e+07 3.21e+28


      Can someone please guide how can I obtain the Odds ratio for interaction terms separately for Male and Female. Its a very important query I am unable to find answer for my supervisor at work really wants me to find answer for this please can someone help. Thanks in advance



      Comment


      • #4
        Dear Cansu Oymak thank you for your reply

        I am a little confused as to how to generate:

        1) generate "female" binary variable taking value of 1 if F and 0 if M.
        2) generate "male" binary variable taking value of 1 if M and 0 if M

        when the gender variable being used in the analysis is coded as 0 for male and 1 for female??

        Comment


        • #5
          Cansu Oymak I did the following for female and male please let me know if its right or wrong

          . generate female= 1 if Gender == 1
          (7,990 missing values generated)

          . tab female

          female | Freq. Percent Cum.
          ------------+-----------------------------------
          1 | 3,683 100.00 100.00
          ------------+-----------------------------------
          Total | 3,683 100.00

          . replace female= 0 if female ==.
          (7,990 real changes made)

          . generate male= 1 if Gender == 1
          (7,990 missing values generated)

          . replace male = 0 if male ==.
          (7,990 real changes made)

          . tab male

          male | Freq. Percent Cum.
          ------------+-----------------------------------
          0 | 7,990 68.45 68.45
          1 | 3,683 31.55 100.00
          ------------+-----------------------------------
          Total | 11,673 100.00

          . tab female

          female | Freq. Percent Cum.
          ------------+-----------------------------------
          0 | 7,990 68.45 68.45
          1 | 3,683 31.55 100.00
          ------------+-----------------------------------
          Total | 11,673 100.00

          Comment


          • #6
            Yes. This is what I have just suggested. For dummy variable "female" you can analyze females only and you can use interaction terms using age or ami. Please note that stata does not provide marginal effects for interaction terms if you type like this i.dummy#c.continous or i.dummy#i.dummy. Instead, you only get the coefs. To overcome this problem, please generate your interaction terms manually. Then, you can get odds ratios or marginal effects.

            Comment


            • #7
              Cansu Oymak but isn't this wrong because the total of the male is 11,673 and female is also 11,673 and even when I analyzed them in a model without interactions female gets omitted and it gives OR for male, and marginal effects give predicted probabilities but I want Odds ratio ??

              . logistic mortality i.male i.female age_10 ibn.AMI_type ib(0).Diabetes ib(0).dyslipidemia_1 ib(0).Hypertension Discharge_Year ib(0).PTCAP
              > CI, noconstant
              note: 1.female omitted because of collinearity

              Logistic regression Number of obs = 11,673
              Wald chi2(9) = 4343.89
              Log likelihood = -3364.0709 Prob > chi2 = 0.0000

              --------------------------------------------------------------------------------
              mortality | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
              ---------------+----------------------------------------------------------------
              1.male | 1.22991 .0849395 3.00 0.003 1.074207 1.408181
              1.female | 1 (omitted)
              age_10 | 1.510117 .0442539 14.07 0.000 1.425824 1.599392
              |
              AMI_type |
              STEMI | 3.97e+18 4.87e+19 3.49 0.000 1.46e+08 1.08e+29
              NSTEMI | 1.43e+18 1.76e+19 3.41 0.001 5.12e+07 4.01e+28
              |
              Diabetes |
              Yes | 1.284302 .087296 3.68 0.000 1.124112 1.467319
              |
              dyslipidemia_1 |
              Yes | .3373005 .0333973 -10.98 0.000 .2778028 .4095409
              |
              Hypertension |
              Yes | .9654826 .0723664 -0.47 0.639 .8335734 1.118266
              Discharge_Year | .9769106 .0059752 -3.82 0.000 .9652692 .9886923
              |
              PTCAPCI |
              Yes | .4892884 .039026 -8.96 0.000 .4184778 .5720809
              --------------------------------------------------------------------------------

              Comment


              • #8
                Dear Maarten Buis thank you so much for the reply I tried the lincom command but I got OR for female only which I am already getting in the multivariable-adjusted model I wanted Odds ratio for both male and female separately do you have any comment

                lincom 0.Gender + 0.Gender#c.age_10, or

                ( 1) [mortality]0b.Gender + [mortality]0b.Gender#co.age_10 = 0

                ------------------------------------------------------------------------------
                mortality | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
                -------------+----------------------------------------------------------------
                (1) | 1 (omitted)
                ------------------------------------------------------------------------------

                . lincom 1.Gender + 1.Gender#c.age_10, or

                ( 1) [mortality]1.Gender + [mortality]1.Gender#c.age_10 = 0

                ------------------------------------------------------------------------------
                mortality | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
                -------------+----------------------------------------------------------------
                (1) | 2.784438 1.032236 2.76 0.006 1.346429 5.758265
                ------------------------------------------------------------------------------

                Last edited by anam ali; 16 May 2021, 08:44.

                Comment


                • #9
                  Dear Sir Clyde Schechter can you please help with my query if possible would be extremely grateful for your time and efforts

                  Comment


                  • #10
                    Here is an example:

                    .
                    Code:
                    . // open example data
                    . sysuse nlsw88, clear
                    (NLSW, 1988 extract)
                    
                    .
                    . // prepare the data
                    .
                    . gen byte black = race == 2 if !missing(race)
                    
                    . label variable black "respondent's race"
                    
                    . label define black 0 "not black" ///
                    >                    1 "black"
                    
                    . label value black black
                    
                    .
                    . gen byte urban = c_city + smsa
                    
                    . label define urban 2 "central city" ///
                    >                    1 "suburban"     ///
                    >                    0 "rural"
                    
                    . label value urban urban
                    
                    . label variable urban "urbanicity"
                    
                    .
                    . gen grade_c = grade - 12
                    (2 missing values generated)
                    
                    . label var grade_c "current grade completed (centered at 12)"
                    
                    .
                    . logit never_married i.black##c.grade_c i.urban i.south, or
                    
                    Iteration 0:   log likelihood = -750.35422  
                    Iteration 1:   log likelihood = -700.91937  
                    Iteration 2:   log likelihood = -695.33561  
                    Iteration 3:   log likelihood = -695.32636  
                    Iteration 4:   log likelihood = -695.32636  
                    
                    Logistic regression                             Number of obs     =      2,244
                                                                    LR chi2(6)        =     110.06
                                                                    Prob > chi2       =     0.0000
                    Log likelihood = -695.32636                     Pseudo R2         =     0.0733
                    
                    ---------------------------------------------------------------------------------
                      never_married | Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
                    ----------------+----------------------------------------------------------------
                              black |
                             black  |   3.782607   .6961037     7.23   0.000     2.637223     5.42545
                            grade_c |   1.239818   .0474363     5.62   0.000     1.150245    1.336367
                                    |
                    black#c.grade_c |
                             black  |   .7904653   .0446505    -4.16   0.000     .7076223     .883007
                                    |
                              urban |
                          suburban  |   .9448063   .1903419    -0.28   0.778     .6365882    1.402255
                      central city  |   1.894218   .3631246     3.33   0.001     1.300928    2.758078
                                    |
                            1.south |   .6305354   .0982841    -2.96   0.003     .4645465    .8558344
                              _cons |   .0553448   .0105848   -15.13   0.000     .0380438    .0805137
                    ---------------------------------------------------------------------------------
                    Note: _cons estimates baseline odds.
                    
                    . lincom grade_c + 1.black#c.grade_c, or
                    
                     ( 1)  [never_married]grade_c + [never_married]1.black#c.grade_c = 0
                    
                    ------------------------------------------------------------------------------
                    never_marr~d | Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
                    -------------+----------------------------------------------------------------
                             (1) |   .9800335   .0410871    -0.48   0.630      .902724    1.063964
                    ------------------------------------------------------------------------------
                    The normal logit model give you the estimate of grade when someone is white. With lincom you can get the estimate of grade for people who are black.

                    You can get the same estimates using

                    Code:
                    . logit never_married ibn.black i.black#c.grade_c i.urban i.south, or nocons
                    
                    Iteration 0:   log likelihood = -1555.4223  
                    Iteration 1:   log likelihood = -709.08567  
                    Iteration 2:   log likelihood = -695.64862  
                    Iteration 3:   log likelihood = -695.32652  
                    Iteration 4:   log likelihood = -695.32636  
                    Iteration 5:   log likelihood = -695.32636  
                    
                    Logistic regression                             Number of obs     =      2,244
                                                                    Wald chi2(7)      =     851.87
                    Log likelihood = -695.32636                     Prob > chi2       =     0.0000
                    
                    ---------------------------------------------------------------------------------
                      never_married | Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
                    ----------------+----------------------------------------------------------------
                              black |
                         not black  |   .0553448   .0105848   -15.13   0.000     .0380438    .0805137
                             black  |   .2093476   .0446847    -7.33   0.000     .1377784    .3180933
                                    |
                    black#c.grade_c |
                         not black  |   1.239818   .0474363     5.62   0.000     1.150245    1.336367
                             black  |   .9800335   .0410871    -0.48   0.630      .902724    1.063964
                                    |
                              urban |
                          suburban  |   .9448063   .1903419    -0.28   0.778     .6365882    1.402255
                      central city  |   1.894218   .3631246     3.33   0.001     1.300928    2.758078
                                    |
                            1.south |   .6305354   .0982841    -2.96   0.003     .4645465    .8558344
                    ---------------------------------------------------------------------------------
                    This is discussed in the Stata Tip I linked to earlier in #2
                    ---------------------------------
                    Maarten L. Buis
                    University of Konstanz
                    Department of history and sociology
                    box 40
                    78457 Konstanz
                    Germany
                    http://www.maartenbuis.nl
                    ---------------------------------

                    Comment


                    • #11
                      Dear Maarten Buis since you mentioned the normal logit model give you the estimate of grade when someone is white how is it giving for white because as per the example in the model it is giving OR for black while taking white as reference category even the interaction consist of black, yes I can see with lincom the estimate is for grade for people who are black. Also, the lincom is giving OR for the interaction term which is mentioned in the model, which is lincom grade_c + 1.black#c.grade_c, or and not giving OR for not black category.
                      This is exactly what's happening with me as you can see in #1 my interaction term is giving OR for females not for males so when I use lincom it is giving OR for females only and for males it is getting omitted mentioned in #8. Please let me know where I am making a mistake would be extremely thankful.


                      Also, the part where you mentioned I can get an estimate using the following method I did that please review:

                      When I remove age_10 and AMI type from the model I get ORs for male and female separately for interaction terms, but why is OR for gender variable coming in this form (male:1.12e+18, female:3.70e+18) ?? I also want OR for age_10 and AMI type as well in my model what to do about that please suggest


                      . logit mortality ibn.Gender ib(0).Diabetes ib(0).dyslipidemia_1 ib(0).Hypertension Discharge_Year ib(0).PTCAPCI c.age_10#Gender b(2).AMI_type#Gender,or nocons

                      Iteration 0: log likelihood = -8091.107
                      Iteration 1: log likelihood = -3464.0954
                      Iteration 2: log likelihood = -3359.1581
                      Iteration 3: log likelihood = -3355.5102
                      Iteration 4: log likelihood = -3355.4983
                      Iteration 5: log likelihood = -3355.4983

                      Logistic regression Number of obs = 11,673
                      Wald chi2(11) = 4324.04
                      Log likelihood = -3355.4983 Prob > chi2 = 0.0000

                      ---------------------------------------------------------------------------------
                      mortality | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
                      ----------------+----------------------------------------------------------------
                      Gender |
                      Male | 1.12e+18 1.38e+19 3.38 0.001 3.91e+07 3.21e+28
                      Female | 3.70e+18 4.55e+19 3.48 0.000 1.30e+08 1.06e+29
                      |
                      Diabetes |
                      Yes | 1.258716 .0857974 3.38 0.001 1.101305 1.438626
                      |
                      dyslipidemia_1 |
                      Yes | .3368114 .0333947 -10.98 0.000 .2773259 .4090563
                      |
                      Hypertension |
                      Yes | .9556454 .0715644 -0.61 0.545 .8251896 1.106725
                      Discharge_Year | .9769054 .0059796 -3.82 0.000 .9652556 .9886958
                      |
                      PTCAPCI |
                      Yes | .4894141 .0390456 -8.96 0.000 .4185693 .5722497
                      |
                      Gender#c.age_10 |
                      Male | 1.591416 .0581228 12.72 0.000 1.481479 1.709511
                      Female | 1.339983 .0649256 6.04 0.000 1.218587 1.473473
                      |
                      AMI_type#Gender |
                      STEMI#Male | 2.462539 .2253916 9.85 0.000 2.058137 2.946402
                      STEMI#Female | 3.432272 .38052 11.12 0.000 2.761931 4.265308
                      ---------------------------------------------------------------------------------


                      ORs for male and female don't get generated when age_10 and AMI type

                      logit mortality ibn.Gender age_10 ib(2).AMI_type ib(0).Diabetes ib(0).dyslipidemia_1 ib(0).Hypertension Discharge_Year ib(0).PTCAPCI c.age_10#Gender b(2).AMI_type#Gender, or nocons

                      note: 1.Gender#c.age_10 omitted because of collinearity
                      note: 1.AMI_type#1.Gender omitted because of collinearity
                      Iteration 0: log likelihood = -8091.107
                      Iteration 1: log likelihood = -3464.0954
                      Iteration 2: log likelihood = -3359.1581
                      Iteration 3: log likelihood = -3355.5102
                      Iteration 4: log likelihood = -3355.4983
                      Iteration 5: log likelihood = -3355.4983

                      Logistic regression Number of obs = 11,673
                      Wald chi2(11) = 4324.04
                      Log likelihood = -3355.4983 Prob > chi2 = 0.0000

                      ---------------------------------------------------------------------------------
                      mortality | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
                      ----------------+----------------------------------------------------------------
                      Gender |
                      Male | 1.12e+18 1.38e+19 3.38 0.001 3.91e+07 3.21e+28
                      Female | 3.70e+18 4.55e+19 3.48 0.000 1.30e+08 1.06e+29
                      |
                      age_10 | 1.339983 .0649256 6.04 0.000 1.218587 1.473473
                      |
                      AMI_type |
                      STEMI | 3.432272 .38052 11.12 0.000 2.761931 4.265308
                      |
                      Diabetes |
                      Yes | 1.258716 .0857974 3.38 0.001 1.101305 1.438626
                      |
                      dyslipidemia_1 |
                      Yes | .3368114 .0333947 -10.98 0.000 .2773259 .4090563
                      |
                      Hypertension |
                      Yes | .9556454 .0715644 -0.61 0.545 .8251896 1.106725
                      Discharge_Year | .9769054 .0059796 -3.82 0.000 .9652556 .9886958
                      |
                      PTCAPCI |
                      Yes | .4894141 .0390456 -8.96 0.000 .4185693 .5722497
                      |
                      Gender#c.age_10 |
                      Male | 1.187639 .0713938 2.86 0.004 1.055638 1.336145
                      Female | 1 (omitted)
                      |
                      AMI_type#Gender |
                      STEMI#Male | .7174662 .0990926 -2.40 0.016 .5473158 .9405132
                      STEMI#Female | 1 (omitted)
                      ---------------------------------------------------------------------------------

                      .


                      Comment


                      • #12
                        Originally posted by anam ali View Post
                        _cons 1.12e+18 1.38e+19 3.38 0.001 3.91e+07 3.21e+28


                        . . . my supervisor at work really wants me to find answer for this . . .
                        If I were your supervisor at work, I'd be more interested in your investigating further into what's behind that.

                        It would certainly warrant checking the data, work flow &c. before anyone gets too hung up about sex differences in ST segment elevation in the EKG.

                        Comment

                        Working...
                        X