GLM with categorical predictor on R

I need to do a model with a generalized linear model. My data are these: habitat : 0 or 1, group : 1 or 0 , mortality : yes or no, and the numbers of individuals for each case (habitat, group and mortality are factors). My model is glm(moratily~indiv+habitat+group,data,family=binomial(logit))

I want to see the influence of groupe and habitat on mortality.

and I get this message error : Warning message: glm.fit: fitted probabilities numerically 0 or 1 occurred

So what's wrong?

• which means the fitted probabilities are just 0 and 1, p(y|x)=0 or 1. you may table(group, mortality) or table(habitat, mortality) to see whether they are perfectly grouped. That might be the reason. – David Z Aug 1 '14 at 19:19

This warning means that the data are separated, i.e. that these features are able to perfectly classify the response. This isn't intrinsically a bad thing, and many classification techniques have no problem with it, but logistic regression does not like it. This is because logistic regression uses the log odds which are defined as $$log\left(\frac{p(y = 1 | X = x)}{1-p(y = 1 | X = x)}\right).$$
Note how if either $p(y = 1 | X = x) = 1$ or $p(y = 1 | X = x) = 0$ then the log odds will be undefined. This is why that warning appears.