You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Logit returns nan p-value for some coefficients #3367
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
=================================================================
This is the cov_params I get:
array([ -1.75921860e+13, -1.75921860e+13, -1.75921860e+13,
-1.75921860e+13, -1.75921860e+13, 2.21259433e-02,
2.73927583e-01, 4.82831551e+01, 2.78065895e-02])
Indeed some of them are negative.
I can bootstrap the model and get confidence interval numerically. I think
statmodels should be able to do so as well.
On Sun, Jan 8, 2017 at 8:31 PM, Josef Perktold ***@***.***> wrote:
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.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3367 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AXPZfpI6ffJkFR1GvY1tYXRNzg0jCn22ks5rQSuKgaJpZM4LdwbZ>
.
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.
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.
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.
Activity
josef-pkt commentedon Jan 8, 2017
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.
chananshgong commentedon Jan 8, 2017
josef-pkt commentedon Jan 8, 2017
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.
ParsaAkbari commentedon Oct 2, 2019
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.
josef-pkt commentedon Oct 2, 2019
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.