Python and Panda newbie here. I'm trying to use statsmodels to fit a logistic regression to calculate the probability that a voter casts a ballot. I'm working at the precinct level; so sometimes the function doesn't converge, and I get the following error: Warning: Maximum number of iterations has been exceeded.
I have already increased the maximum number of iterations to 1000. I then tried to turn that "Warning" into an exception. I have imported warnings and included warnings.simplefilter('error', Warning) to try to capture it, but it doesn't seem to be a true Python warning. Rather, it's something that statsmodels prints out when it hits the maximum number of iterations.
So now I'm wondering if there's a way to say:
if sm.Logit(y, covs).fit(maxiter=1000) doesn't converge:
do something else