Announcement

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

  • "predicts failure perfectly"

    I DO A LOGISTIC REGRESSION AND GET THIS:

    logistic bas dose15 sex
    note: sex != 1 predicts failure perfectly
    sex dropped and 15 obs not used


    Logistic regression Number of obs = 88
    LR chi2(1) = 0.00
    Prob > chi2 = 0.9569
    Log likelihood = -55.041781 Pseudo R2 = 0.0000

    ------------------------------------------------------------------------------
    bas | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    dose15 | .9683794 .5768124 -0.05 0.957 .3013213 3.112156
    sex | 1 (omitted)
    _cons | .4693878 .1186413 -2.99 0.003 .2860119 .7703347
    ------------------------------------------------------------------------------

    Here is my data, I appreciate if someone can tell me what am I doing wrong:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte bas long sex
    1 1
    0 1
    1 1
    1 1
    0 1
    0 1
    0 0
    0 1
    1 1
    0 1
    0 0
    0 1
    1 1
    0 0
    1 1
    0 1
    1 1
    0 1
    0 1
    0 0
    0 0
    0 0
    0 1
    1 1
    1 1
    1 1
    0 1
    0 1
    0 1
    0 1
    0 1
    0 1
    0 1
    1 1
    0 1
    0 1
    1 1
    0 1
    0 1
    0 1
    0 1
    0 1
    0 1
    0 1
    0 1
    1 1
    0 1
    0 1
    0 1
    0 1
    0 1
    0 0
    0 1
    1 1
    1 1
    0 1
    0 1
    1 1
    0 1
    0 1
    0 1
    0 1
    0 0
    1 1
    0 1
    0 1
    1 1
    0 1
    1 1
    1 1
    0 1
    0 1
    0 1
    1 1
    0 1
    1 1
    0 1
    0 0
    0 1
    1 1
    0 1
    1 1
    0 1
    0 1
    0 0
    1 1
    0 1
    0 1
    0 0
    0 1
    0 1
    0 1
    1 1
    0 0
    0 1
    0 1
    0 0
    0 1
    0 0
    1 1
    end
    label values sex sex
    label def sex 0 "Mujer", modify
    label def sex 1 "Hombre", modify
    THANKS!!

  • #2
    The message means exactly what it says. Whenever sex = 0 ("Mujer"), bas = 1 in your data. Otherwise put, you have no observations with sex = 0 and bas = 0. Logistic regression models are fit by maximum likelihood. When there is perfect prediction of the outcome by one value of the predictor variable like this, the maximum likelihood estimate of the logistic regression coefficient is infinite (negative infinity in this case.) That model can never converge. Stata's solution (and that of all the other major statistical packages I am aware of) is to omit the offending level of the predictor variable and all of the associated observations. You then simply state that your model applies only to sex = 1 ("Hombre"). You don't need a model for sex = 0, because the answer is always bas = 0.

    So the first question is, is there something wrong with your data? Should there be cases of sex = 0 and bas = 1 in the data? If so, why aren't they actually there? If the combination of sex = 0 and bas = 1 is very rare in the world, then it may be that your sample was just too small to include any of them. Or, if it's not just an unlucky sample, it suggests that something went wrong in the creation of this data set--in which case you have to review the data management up to that point and find and fix the error(s).

    If the data is really correct as is, and sex = 0, bas = 1 never occurs, or occurs so rarely that a realistic sample size is unlikely to capture it, then your options are to:

    1. Accept that fact and go with modeling only males, given that no model is really needed for females.

    2. Do the analysis using an estimator that does not rely on maximum likelihood. Joseph Coveney's -firthlogit- command, available from SSC, will run this using penalized maximum likelihood estimation, which is suitable for data with perfect prediction or rare events.

    Comment


    • #3
      My database only includes 103 observations so I think my sample is just to small to include any "bas" for women. I will do the model only with males then.

      I really appreciate your answer, Thank you so much Clyde!!

      Comment

      Working...
      X