Announcement

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

  • CI for odds ratio for SD increase (logistic regression)?

    Hi

    What is the easiest way of getting a CI for the odds ratio for a SD increase in a continuous independent variable in a logistic regression?

    In the code below, the listcoef command (in the spost_ado.pkg package) gives OR of 1.492 for a SD increase in gpa (in a logistic regression model with the admit variable as the outcome).

    What's the easiest way of getting a 95% CI for that value? I am looking for a prewritten program, rather than creating a variable such as gpa/sd(gpa) every time or calculating the interval myself from returned values. I'm lazy.

    Thanks,

    Jane

    Code:
    . * would install spost13_ado if not already installed
    . * net install spost13_ado.pkg
    
    . use https://stats.idre.ucla.edu/stat/stata/dae/binary.dta, clear
    
    . logistic admit gpa
    
    Logistic regression                                     Number of obs =    400
                                                            LR chi2(1)    =  13.01
                                                            Prob > chi2   = 0.0003
    Log likelihood = -243.48381                             Pseudo R2     = 0.0260
    
    ------------------------------------------------------------------------------
           admit | Odds ratio   Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             gpa |   2.860821   .8550121     3.52   0.000     1.592548    5.139121
           _cons |   .0128093   .0132616    -4.21   0.000     .0016837    .0974513
    ------------------------------------------------------------------------------
    Note: _cons estimates baseline odds.
    
    . listcoef, help
    
    logit (N=400): Factor change in odds
    
      Odds of: 1 vs 0
    
    ------------------------------------------------------------------------
                 |         b        z    P>|z|       e^b   e^bStdX     SDofX
    -------------+----------------------------------------------------------
             gpa |    1.0511    3.517    0.000     2.861     1.492     0.381
        constant |   -4.3576   -4.209    0.000         .         .         .
    ------------------------------------------------------------------------
           b = raw coefficient
           z = z-score for test of b=0
       P>|z| = p-value for z-test
         e^b = exp(b) = factor change in odds for unit increase in X
     e^bStdX = exp(b*SD of X) = change in odds for SD increase in X
       SDofX = standard deviation of X

  • #2
    Code:
    use https://stats.idre.ucla.edu/stat/stata/dae/binary.dta, clear
    logistic admit gpa
    qui sum gpa if e(sample)
    nlcom _b[gpa]*`r(sd)', eform post
    Res.:

    Code:
    . logistic admit gpa
    
    Logistic regression                                     Number of obs =    400
                                                            LR chi2(1)    =  13.01
                                                            Prob > chi2   = 0.0003
    Log likelihood = -243.48381                             Pseudo R2     = 0.0260
    
    ------------------------------------------------------------------------------
           admit | Odds ratio   Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             gpa |   2.860821   .8550121     3.52   0.000     1.592548    5.139121
           _cons |   .0128093   .0132616    -4.21   0.000     .0016837    .0974513
    ------------------------------------------------------------------------------
    Note: _cons estimates baseline odds.
    
    . 
    . qui sum gpa if e(sample)
    
    . 
    . nlcom _b[gpa]*`r(sd)', eform post
    
           _nl_1: _b[gpa]*.3805667727814795
    
    ------------------------------------------------------------------------------
           admit |     exp(b)   Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
           _nl_1 |    1.49185   .1696827     3.52   0.000      1.19374    1.864407
    ------------------------------------------------------------------------------

    Comment


    • #3
      If you want to know what one standard deviation change in x does, than that is another way of saying that you want the unit of your x to be 1 standard deviation. You change the unit to standard deviations by dividing that variable by the standard deviation.

      Code:
      
      . use https://stats.idre.ucla.edu/stat/stata/dae/binary.dta, clear
      
      .
      . logit admit gpa, or
      
      Iteration 0:  Log likelihood = -249.98826  
      Iteration 1:  Log likelihood = -243.52489  
      Iteration 2:  Log likelihood = -243.48382  
      Iteration 3:  Log likelihood = -243.48381  
      
      Logistic regression                                     Number of obs =    400
                                                              LR chi2(1)    =  13.01
                                                              Prob > chi2   = 0.0003
      Log likelihood = -243.48381                             Pseudo R2     = 0.0260
      
      ------------------------------------------------------------------------------
             admit | Odds ratio   Std. err.      z    P>|z|     [95% conf. interval]
      -------------+----------------------------------------------------------------
               gpa |   2.860821   .8550121     3.52   0.000     1.592548    5.139121
             _cons |   .0128093   .0132616    -4.21   0.000     .0016837    .0974513
      ------------------------------------------------------------------------------
      Note: _cons estimates baseline odds.
      
      . listcoef
      
      logit (N=400): Factor change in odds
      
        Odds of: 1 vs 0
      
      ------------------------------------------------------------------------
                   |         b        z    P>|z|       e^b   e^bStdX     SDofX
      -------------+----------------------------------------------------------
               gpa |    1.0511    3.517    0.000     2.861     1.492     0.381
          constant |   -4.3576   -4.209    0.000         .         .         .
      ------------------------------------------------------------------------
      
      .
      . sum gpa if !missing(admit, gpa)
      
          Variable |        Obs        Mean    Std. dev.       Min        Max
      -------------+---------------------------------------------------------
               gpa |        400      3.3899    .3805668       2.26          4
      
      . gen s_gpa = gpa / r(sd)
      
      . logit admit s_gpa, or
      
      Iteration 0:  Log likelihood = -249.98826  
      Iteration 1:  Log likelihood = -243.52489  
      Iteration 2:  Log likelihood = -243.48382  
      Iteration 3:  Log likelihood = -243.48381  
      
      Logistic regression                                     Number of obs =    400
                                                              LR chi2(1)    =  13.01
                                                              Prob > chi2   = 0.0003
      Log likelihood = -243.48381                             Pseudo R2     = 0.0260
      
      ------------------------------------------------------------------------------
             admit | Odds ratio   Std. err.      z    P>|z|     [95% conf. interval]
      -------------+----------------------------------------------------------------
             s_gpa |    1.49185   .1696827     3.52   0.000      1.19374    1.864407
             _cons |   .0128093   .0132617    -4.21   0.000     .0016837    .0974514
      ------------------------------------------------------------------------------
      Note: _cons estimates baseline odds.
      I only added listcoef to show that the odds ratio you get there is the same as the odds ratio you get when creating a new variable. That is the only reason, so in a real analysis you can leave that out.
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment


      • #4
        Many thanks to Andrew and Maarten for their replies. I sort of think it's funny that I wrote: "I am looking for a prewritten program, rather than creating a variable such as gpa/sd(gpa) every time or calculating the interval myself from returned values. I'm lazy" and then I got both of those solutions.

        I wasn't actually giving the true reason for asking the question as I did. I said that it was because I was lazy because I felt that I had to give some sort of rationale. The true reason is that I am working with a colleague who is doing the coding. She, while expert in her own field, isn't very good at some statistical concepts or at statistical programming. I wanted an "out of the box" solution that would appeal to her and be easy for her. I do hope that she doesn't Google me for some reason and read this.

        While I admire the elegance of Andrew's method, if I were coding it myself, I would use Maarten's approach. That way you get to see the standardised variable in familiar output with other variables in the model.

        I was maybe being over-pessimistic in thinking that my colleague wouldn't be happy with using r(sd) results from a "summ" command in generating standardised variables and will suggest that to her. I know that left to her own devices, she would hard code the numerical values of the SDs in her do file.

        It actually took some finding to get even the listcoef command. I don't know why the authors didn't consider adding CIs as an option. It's an obvious thing to want to do, as it is more informative than just a point estimate and p-value.

        Comment

        Working...
        X