py-econometrics / pyfixest

Fast High-Dimensional Fixed Effects Regression in Python following fixest-syntax
https://py-econometrics.github.io/pyfixest/pyfixest.html
MIT License
130 stars 29 forks source link

Helping demean() Fail Gracefully - Add a'fixef_iter' argument to feols() and fepois() #539

Open b-knight opened 1 month ago

b-knight commented 1 month ago

I've encountered instances when demean_.demean() runs endlessly - probably because I passed it a poorly structured data shape. I would like to be able to call a service that uses PyFixest, so calling the package on problematic data is a distinct possibility.

To this end, it would be great if there were ways to help the demean() method fail gracefully. Having some sort of mechanism for timing out could be handy, but the simplest approach that I can think of off hand is to make the 'maxiter' argument accessible from the feols() method in a manner similar to how the 'fixef_tol' argument is accessible to the user.

s3alfisc commented 1 month ago

Yes, I agree - it would be great to add a fixef_iter function argument to pyfixest.estimation.feols and pyfixest.estimation.fepois that would allow users to set the maximum number of iterations for the demeaning algo.

Overall, this should be straightforward enough: