Skip to content

FAQ corner case: perfect predictability, perfect separation #1705

Open

Description

@josef-pkt

Since I was just reading the section in the Stata manual for Probit

A question that was just asked on the LinkedIn Econometrics group

Logistic Regression Drops Variable of Interest

Hello. I am running a logistic regression, but one of the variables of interest has no observations 
in one of the categories of the dependent variable. So, basically, for x=1, y is always 1. For x=0, 
y can be both 0 or 1. When i run this model, logistic regression essentially omits this variable 
because of perfect predictability. But this is a variable of interest. A friend of mine suggested 
that if i introduce a random error term into x, then we can preserve the coefficient by "tricking" 
stata into estimating this coefficient. So, basically, instead of x, i now have the regression with 
a new variable, x1 = x + random normal with mean zero, and std div small but greater than zero. 
This does indeed give me a coefficient! The question I have for this group is whether this is a 
fairly well known technique or not. I searched Google but did not find any discussions about it, 
so hoping that you can help me.

I think I don't like the automatic "cleaning" of the data by Stata. But we should be able to provide tools to get around corner cases like perfect separation. (After users got the exception.)

Activity

  1. josef-pkt commented on May 29, 2014

    @josef-pkt
    MemberAuthor

    As explanation: Stata checks for perfect prediction cases, and if there is, then it drops the perfectly prediction variable and removes the affected observations.
    This happens if only one of the "states" choices can be perfectly predicted. If all can be perfectly predicted, then also Stata returns with an error message.
    (according to the Stata manual for Probit, and IVProbit.)

  2. josef-pkt commented on Feb 28, 2015

    @josef-pkt
    MemberAuthor

    related open issues
    #659
    #2282

  3. soumyadsanyal commented on Jul 23, 2015

    @soumyadsanyal

    Hi, I'm new to statsmodels, and this thread. I'd like to work on this issue, and I have some related questions:

    1. I'd like to clarify that we do want to implement functionality to raise an exception in the case of perfect separation (using techniques from Konis' thesis?), and provide tools to deal with these cases in the Logit and MNLogit methods?

    2. Is anyone else currently working on this issue? (I'd prefer not to duplicate work.) Do I need this issue to be assigned to me to eventually make a pull request?

  4. josef-pkt commented on Jul 23, 2015

    @josef-pkt
    MemberAuthor

    (I'm online only for 5 minutes, so just a brief update)

    The binary models, Logit, Probit in discrete_models raise currently an exception with perfect separation, which can be optionally weakened to a warning (or turned off?)
    We don't check anywhere else yet.
    for MNLogit see http://stackoverflow.com/questions/31507396/mnlogit-in-statsmodel-returning-nan
    GLM binary models also don't check for perfect prediction.

    There are few other related issues open, IIRC.
    There is also an open issue to "handle" perfect separation by penalized MLE or a Bayesian prior.

    We want to warn and detect, but it is not always clear whether the default needs to be raising an exception. I added the option to turn off the perfect separation exception in Logit because I still wanted to get the results instead of a exception.

    Any work would be welcome. Nobody is working on this right now, and nobody mentioned an intention to work on this. My work in cases like these, is to add some parts when I have a bit of time and something induces me to check out that neighborhood of the code.

  5. jseabold commented on Jul 23, 2015

    @jseabold
    Member

    I'm interested in what you come up with based on the work in the Konis paper. My impression from a quick read that it might not be super practical for large-ish datasets, but I'd love to be proved wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions