Skip to content

TST: Add test for PD hessian - #3099

Merged
josef-pkt merged 2 commits into
statsmodels:masterfrom
bashtage:add-eigenvalue-test
Aug 17, 2016
Merged

josef-pkt merged 2 commits into
statsmodels:masterfrom
bashtage:add-eigenvalue-test

Conversation

@bashtage

@bashtage bashtage commented Jul 6, 2016

Copy link
Copy Markdown
Member

Add test for PD hessian
Raise if not PD before inversion

closes #3098
closes #3094

@coveralls

coveralls commented Jul 6, 2016 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.0007%) to 88.812% when pulling 1a3a981 on bashtage:add-eigenvalue-test into c5b2f2e on statsmodels:master.

Comment thread statsmodels/base/model.py Outdated
Hinv = np.linalg.inv(-1 * self.hessian(xopt))
except:
H = -1 * self.hessian(xopt)
w, v = np.linalg.eigh(H)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually prefer, evals, evecs = np.linalg.eigh... to remember which is which

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are already calculating the eigenvalues, then we should keep them.
I think we can add them to mlefit.mle_retvals, retvals see line 474 below

@coveralls

coveralls commented Jul 8, 2016 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.003%) to 88.815% when pulling 2a5fe13 on bashtage:add-eigenvalue-test into c5b2f2e on statsmodels:master.

@bashtage
bashtage force-pushed the add-eigenvalue-test branch from 2a5fe13 to e345b5b Compare July 11, 2016 15:40
@coveralls

coveralls commented Jul 11, 2016 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.001%) to 88.815% when pulling e345b5b on bashtage:add-eigenvalue-test into ba01d87 on statsmodels:master.

Add test for PD hessian
Raise if not PD before inversion

closes statsmodels#3098
closes statsmodels#3094
Remove try, except in hessian inversion
Add custom warning type for hessian inversion
Add check for finite elements before computing eigenvalues
@bashtage
bashtage force-pushed the add-eigenvalue-test branch from e345b5b to 605a006 Compare August 10, 2016 12:13
@coveralls

coveralls commented Aug 10, 2016 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.001%) to 89.185% when pulling 605a006 on bashtage:add-eigenvalue-test into 60bf8a1 on statsmodels:master.

@josef-pkt

Copy link
Copy Markdown
Member

backport label for kalman_loglike,
I'm still not sure we want to change the hessian inversion in 0.8

@bashtage

Copy link
Copy Markdown
Member Author

I think it is pretty harmless and provides the user with more information.

@josef-pkt
josef-pkt merged commit 87fd2d3 into statsmodels:master Aug 17, 2016
@josef-pkt

Copy link
Copy Markdown
Member

merged

@bashtage Thank you

I had forgotten that we might have negative eigenvalues in some cases, #3094.
I still think we need better policy on singular hessian handling, but this is an improvement to the current situation (although maybe a bit slower that the previous version for the positive definite check. But we will need the eigenvalues in any case when we want to handle better the singular and near singular cases.)

josef-pkt added a commit to josef-pkt/statsmodels that referenced this pull request Aug 19, 2016
BUG/REF: hessian: check positive-definite and asfortranarray
@bashtage
bashtage deleted the add-eigenvalue-test branch August 29, 2016 15:12
@TomAugspurger TomAugspurger mentioned this pull request Feb 2, 2017
2 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Kalman filter fails with 1-D complex Z_mat, T_mat, R_mat BUG: Hessian inversion check is inadequate

3 participants