This question already has an answer here:

I am running a logistic regression model in R using glm. I received a warning that complete separation occurred. How do I determine which variable is causing this? R doesn't tell you what variable is the issue.


marked as duplicate by kjetil b halvorsen, mdewey, Peter Flom Jul 13 '18 at 13:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 6
    $\begingroup$ There might not be any single variable that, by itself, causes the problem. How you approach this question therefore might depend on how many variables are involved in the model: with just a few variables you can explore all subsets of them; but with more you would need a better approach. $\endgroup$ – whuber May 25 '18 at 19:08
  • $\begingroup$ There are 10 variables in the model. I've been debating using the logistf package to perform a penalized version of logistic regression. $\endgroup$ – BenW May 25 '18 at 19:12
  • 1
    $\begingroup$ $10$ is small enough that--provided you don't have a huge number of observations--you could simply loop through all nonempty subsets of the variables to see which combinations create perfect separation and which do not. Focusing on just the larger subsets might be good enough to characterize what's going on. $\endgroup$ – whuber May 25 '18 at 22:52
  • $\begingroup$ There is no reason to close this. It's not about R, it's about statistics. $\endgroup$ – Peter Flom May 26 '18 at 13:18

The brglm2 package provides pre-fit and post-fit methods for the detection of separation and of infinite maximum likelihood estimates in binomial response generalized linear models - see the functions detect_separation() and check_infinite_estimates(), which are discussed at https://cran.r-project.org/web/packages/brglm2/vignettes/separation.html.

For an example of using the brglm package and eponymous function to address complete or quasi separation, see https://bscheng.com/2016/12/11/modeling-completely-separated-data-in-r/. This link on brglm may also help: http://www.wekaleamstudios.co.uk/posts/logistic-regression-and-bias-reduction/.

  • 4
    $\begingroup$ Although implementation is often mixed with substantive content in questions, we are supposed to be a site for providing information about statistics, machine learning, etc., not just software. It can be good to provide information on software packages, but please elaborate your substantive answer in text well enough that people who don't use R can recognize & extract the answer. Eg, what is it that these functions are doing such that they can provide an answer? $\endgroup$ – gung May 25 '18 at 21:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.