Skip to content

Logit returns nan p-value for some coefficients #3367

Open

Description

@chananshgong

Why do some Coef. have nan Std.Err, z, P>|z| and CI?
I believe this is a bug.

                         Results: Logit
=================================================================
Model:              Logit            Pseudo R-squared: 0.192     
Dependent Variable: call_value       AIC:              13522.0051
Date:               2017-01-08 20:17 BIC:              13582.4183
No. Observations:   14068            Log-Likelihood:   -6753.0   
Df Model:           7                LL-Null:          -8361.4   
Df Residuals:       14060            LLR p-value:      0.0000    
Converged:          1.0000           Scale:            1.0000    
--------------------------------------------------------------------
       Coef.     Std.Err.       z       P>|z|      [0.025     0.975]
--------------------------------------------------------------------
x1    -0.2207         nan        nan       nan        nan        nan
x2     0.0377         nan        nan       nan        nan        nan
x3    -2.4384         nan        nan       nan        nan        nan
x4     1.3972         nan        nan       nan        nan        nan
x5     0.7828         nan        nan       nan        nan        nan
x6    -0.0561      0.1487    -0.3771    0.7061    -0.3476     0.2354
x7    -1.3261      0.5234    -2.5338    0.0113    -2.3520    -0.3003
x8     5.8230      6.9486     0.8380    0.4020    -7.7960    19.4421
x9     0.1786      0.1668     1.0712    0.2841    -0.1482     0.5055
=================================================================

Activity

  1. josef-pkt commented on Jan 8, 2017

    @josef-pkt
    Member

    most likely the exog is singular and the hessian is not positive definite.

    check np.diag(result.cov_params()) which might have negative values that are the cause of the nans.

    That's the only case I have seen nan bse for only some of the parameters.

    If this is the case, then this might be a bug. AFAIK, we have added a check or adjustment for some cases of indefinite hessian in master.

  2. chananshgong commented on Jan 8, 2017

    @chananshgong
    Author
  3. josef-pkt commented on Jan 8, 2017

    @josef-pkt
    Member

    Using bootstrap or any other confidence intervals would not help because they are [-inf, +inf]. your parameters are not identified because of the singular exog or singular estimating equations .
    You need to either drop perfectly collinear columns or use a penalized/regularized or constrained estimator.

  4. ParsaAkbari commented on Oct 2, 2019

    @ParsaAkbari

    Would it be fair to say that the optimisation hasn't converged in a useful way if some parameter estimates are NA or if there are negative values in the variance covariance matrix? If so, perhaps the summary() should not be returning that converged is True in such cases.

  5. josef-pkt commented on Oct 2, 2019

    @josef-pkt
    Member

    It can be that the optimization converged, i.e. it found a local optimum, up to numerical precision and convergence tolerance.

    However, the local optimum is not unique, not even locally, if the design matrix is singular. The parameters are not identified and there is a subspace, or local set of parameters, that has the same maximum likelihood value for parameters in this set.
    i.e. the optimization picks one solution of the optimal set, and "converged" can be correct.

    We get an exception or warning when the hessian is not invertable.

    There were some changes to check that the Hessian is positive semi-definite, which would warn on invertible hessians that have negative variances.
    I'm not sure what the status for that is in discrete models.

    In the original example above, the nans are actually informative because we see which exog variables have problems.

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