(glm.fit: fitted probabilities numerically 0 or 1 occurred) warning message occured for Logistic regression.
Help me resolving this issue.
Glm.fit: fitted probabilities numerically 0 or 1 occurred Warning message when I run Logistic regression
@Ronit
Reproduce the entire problem ronit with code what you are doing. Asking a broad question wonâ€™t help you much.
Regards
Hi @Ronit,
Please elaborate on the dataset that you are working with so that we can give a conclusive suggestion. This error means that the model is predicting absolute probabilities like 0 and 1.
If you feel that in the problem that you are dealing with can have such possibilities, it is advisable to leave this as it is and ignore the warning. However, if you feel that this should not be happening, you could try the following:
 Use bayesglm in the arm package
fit < bayesglm(y ~ x1 + x2+... , data=d, family="binomial")
 Penalize the coefficients of the logistic regression using glmnet.
One of the less userfriendly aspects of glmnet is that you can only feed it matrices, not formulas as weâ€™re used to. However, you can look at model.matrix and the like to construct this matrix from a data.frame and a formula.
fit2=glmnet(x,g2,family="binomial")
Just have a look at the documentations of these packages to see the complete syntax and execution.
Regards,
Shashwat
Hi Shashwat, sorry for bringing out this post from dead. But Iâ€™m facing this problem and whatever solution Iâ€™ve found till date went over my head. Just to let you know, Iâ€™m a newbie to data science and taking part in my first analytics competition.
So here is the issue,
I have about 9 predictors and iâ€™m trying to predict a student placement through these variables. Though I have already built my model using Forward selection and have achieved about 96% accuracy, iâ€™m still wondering if I can enhance it by using other predictors that are creating the problem of â€śglm.fit: fitted probabilities numerically 0 or 1 occurredâ€ť. Based on your questions above, here are the answers:

No the problem cannot have any such probabilities to have exact 0 or 1.

As a result of this warning, all my model values are inflated. In fact all my pvalues for predictors are coming out to be 1, strange isnâ€™t it?

I just tried the baysian glm and got following warning : â€śfitted probabilities numerically 0 or 1 occurredâ€ť

I couldnâ€™t understand that glmnet solution that you gave, actually I found the same solution somewhere else on net as well but couldnâ€™t decipher it. Can you please explain it?
Please feel free to ask for any other details and I will provide it.
Awaiting your reply.
Thanks
gaurav
Hi Gaurav
I am facing similar problem as yours. Were you able to find a solution for this warning ? Really appreciate your help.
Thanks
Pooja
Hi Pooja,
Yes I was able to
Based on my research, I found that this error occurs mostly due to following 2 reasons:

When one of your IVâ€™s are able to segregate the DV perfectly well. Means, for a particular value of IVâ€™s you can always say that one of the two outcomes (of the DV) exists.

When number of fisher scoring iteration (by defalut 25, I guess) are not enough for convergence.
What to do?

Instead of complete logistic regression, try step wise logit and see which variable is creating the perfect separation.

To increase the number of fisher scoring, try adding this to your existing code : â€ścontrol=glm.control(maxit=50)â€ť. Value of maxit can be changed ofcourse.
For a detailed information on this topic refer Dealing with perfect separation in logit.
Hope this helps.
Peace.