ENH: Improve exception when estimation of kappa is preventing fitting an IV2SLS model
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!
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.
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!