Announcement

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

  • Logit Regression: Calculating the value of a continuous independent var corresponding to a 0.5 probability value of an event occuring

    Hi there,

    I have run a logit regression and I am now trying to determine the value of a continuous variable that corresponds to a 0.5 probability of an event occurring. In my code below, I am trying to find the value of cont1 that corresponds to 0.5 probability of event == 1. I realise that this will depend on cont2, so it would be useful if I could include a way of setting cont2 to a specific, but adjustable value, then being able to calculate the value of cont1 at prob 0.5 from that.

    logit event cont1 cont2
    margins, at(cont1=(0(0.1)6))
    I would be very grateful for some advice!

    Many thanks,
    Jack

  • #2
    The predicted probability is 0.5 when the linear predictor is 0 So

    \[\beta_0 + \beta_1 x_1 + \beta_2 x_2 = 0\]

    And we are looking for a value of \(x_2\) where this is true for a given value of \(x_1\)

    \[\beta_2 x_2 = -\beta_0 - \beta_1 x_1 \Rightarrow x_2 = - \frac{\beta_0 + \beta_1 x_1}{\beta_2}\]

    In an example:
    Code:
    . clear all
    
    . sysuse nlsw88
    (NLSW, 1988 extract)
    
    .
    . logit union grade tenure
    
    Iteration 0:  Log likelihood = -1040.9971  
    Iteration 1:  Log likelihood = -1019.7881  
    Iteration 2:  Log likelihood = -1019.5953  
    Iteration 3:  Log likelihood = -1019.5953  
    
    Logistic regression                                     Number of obs =  1,866
                                                            LR chi2(2)    =  42.80
                                                            Prob > chi2   = 0.0000
    Log likelihood = -1019.5953                             Pseudo R2     = 0.0206
    
    ------------------------------------------------------------------------------
           union | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
           grade |   .0720392    .021608     3.33   0.001     .0296882    .1143902
          tenure |   .0485961   .0092647     5.25   0.000     .0304376    .0667545
           _cons |   -2.41764   .2967544    -8.15   0.000    -2.999268   -1.836012
    ------------------------------------------------------------------------------
    
    . local at = 5
    
    . di -(_b[_cons] + _b[tenure]*`at')/_b[grade]
    30.187173
    Since the maximum education in the data is 18, this 50% mark happens clearly outside the range of data and is thus quite an extrapolation.

    If you want a confidence interval around this number, then that is a bit complicated as there is a division involved. I would use the bootstrap for that.

    Code:
    program toboot, rclass
        syntax [if] , at(real)
        marksample touse
        logit union grade tenure if `touse'
        return scalar p50 = -(_b[_cons] + _b[tenure]*`at')/_b[grade]
    end
    
    bootstrap p50=r(p50), reps(10000) bca : toboot, at(5)
    
    estat bootstrap, bca  
    
    
    
    Bootstrap results                               Number of obs     =      1,866
                                                    Replications      =      10000
    
          Command: toboot, at(5)
              p50: r(p50)
    
    ------------------------------------------------------------------------------
                 |    Observed               Bootstrap
                 | coefficient       Bias    std. err.  [95% conf. interval]
    -------------+----------------------------------------------------------------
             p50 |   30.187173   3.000599   22.514546    23.60066   57.12771 (BCa)
    ------------------------------------------------------------------------------
    Key: BCa: Bias-corrected and accelerated
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment

    Working...
    X