Announcement

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

  • negative probabilities post GLM

    Hello,

    I ran a logistic regression in Stata as follows:

    glm cost_ind ${sexagespl} $morbs $comorbs *_D2 if s1==1 ,family(binomial) link(logit) eform

    After the model had ran I tried to obtain predicted probabilities using:

    predict double chat if s1==1, p

    However, I am getting negative probabilities. I thought maybe that because I used 'eform' in the command line, and maybe I need to log the results - but that would make no sense for negative numbers.

    I have tried searching for what the issue might be but have not been able to find an answer.
    Last edited by Daniel Sutcliffe; 29 Jul 2022, 07:15.

  • #2
    help glm postestimation##predict explains that predict, p after glm gives you Pearson residuals, which will often be negative and even larger in magnitude than 1 on occasion.

    You just need to drop that option and use the default.

    Code:
    . sysuse auto, clear
    (1978 automobile data)
    
    . glm foreign weight, link(logit) f(binomial)
    
    Iteration 0:   log likelihood = -30.546142  
    Iteration 1:   log likelihood = -29.056683  
    Iteration 2:   log likelihood = -29.054002  
    Iteration 3:   log likelihood = -29.054002  
    
    Generalized linear models                         Number of obs   =         74
    Optimization     : ML                             Residual df     =         72
                                                      Scale parameter =          1
    Deviance         =  58.10800384                   (1/df) Deviance =   .8070556
    Pearson          =  61.02398411                   (1/df) Pearson  =   .8475553
    
    Variance function: V(u) = u*(1-u)                 [Bernoulli]
    Link function    : g(u) = ln(u/(1-u))             [Logit]
    
                                                      AIC             =   .8392973
    Log likelihood   = -29.05400192                   BIC             =  -251.7847
    
    ------------------------------------------------------------------------------
                 |                 OIM
         foreign | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
          weight |  -.0025874   .0006094    -4.25   0.000    -.0037817    -.001393
           _cons |   6.282599   1.603967     3.92   0.000     3.138882    9.426316
    ------------------------------------------------------------------------------
    
    . predict predicted
    (option mu assumed; predicted mean foreign)
    
    . su predicted
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
       predicted |         74    .2972973    .2906982   .0019454   .8492585
    .

    Comment


    • #3
      Thank you

      Comment

      Working...
      X