Don't show SciPy optimisation message in regression
This commit is contained in:
parent
4340be165b
commit
b24f675d57
@ -396,13 +396,17 @@ def regress(
|
||||
|
||||
# Fit model
|
||||
model = model_class.from_formula(formula=dep + ' ~ ' + formula, data=df, **model_kwargs)
|
||||
result = model.fit(**fit_kwargs)
|
||||
result = model.fit(disp=False, **fit_kwargs)
|
||||
|
||||
if isinstance(result, RegressionResult):
|
||||
# Already processed!
|
||||
result.exp = exp
|
||||
return result
|
||||
|
||||
# Check convergence
|
||||
if hasattr(result, 'mle_retvals') and not result.mle_retvals['converged']:
|
||||
warnings.warn('Maximum likelihood estimation failed to converge. Check raw_result.mle_retvals.')
|
||||
|
||||
# Process terms
|
||||
terms = {}
|
||||
|
||||
@ -478,6 +482,10 @@ def logit_then_regress(model_class, df, dep, formula, *, nan_policy='warn', **kw
|
||||
logit_result = regress(sm.Logit, df, dep, formula, **kwargs)
|
||||
logit_params = logit_result.raw_result.params
|
||||
|
||||
# Check convergence
|
||||
if not logit_result.raw_result.mle_retvals['converged']:
|
||||
return None
|
||||
|
||||
# Perform desired regression
|
||||
return regress(model_class, df, dep, formula, start_params=logit_params, **kwargs)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user