Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ENH: Improve exception when estimation of kappa is preventing fitting an IV2SLS model #436

Open
roy1312 opened this issue Jun 15, 2022 · 2 comments
Assignees

Comments

@roy1312
Copy link

roy1312 commented Jun 15, 2022

Hi!

I was trying to fit an IV2SLS model, but a LinAlgError: Eigenvalues did not converge was raised. The error happens when _estimate_kappa is called. More precisely, it happens because the first eigenvalue of ez.T @ ez matrix is -6.98956008e-15. Therefore a problem of taking sqrt of negative number arises when inv_sqrth is called inside the _estimate_kappa function.

But I don't think an estimation of kappa is needed in this case, because 2SLS model assumes kappa = 1. And I succeeded in estimating the parameters by calling function estimate_parameters directly. Is there any way to fit the model without calling _estimate_kappa?
Thanks a lot!

@roy1312 roy1312 closed this as completed Jun 15, 2022
@bashtage
Copy link
Owner

I saw you closed. Presumable this means that Z is not full rank which will cause problems later. This said, it would be good to provide a better error when this happens.

@bashtage bashtage reopened this Jun 15, 2022
@bashtage bashtage changed the title Estimation of kappa is preventing fitting an IV2SLS model ENH: Improve exception when estimation of kappa is preventing fitting an IV2SLS model Jun 15, 2022
@roy1312
Copy link
Author

roy1312 commented Jun 15, 2022

Thanks for the reply! It turns out that I made a mistake in putting the same variable as both the endogenous variable and the instrument. The problem disappears once I correct it. Yes, a better error message that tells me this kind of obvious mistake would save a lot confusion!

@bashtage bashtage self-assigned this Sep 21, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants