Skip to content

Commit

Permalink
MAINT: simplify discrete calls to get_robustcov_results
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Sep 20, 2018
1 parent a764908 commit f32994b
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions statsmodels/discrete/discrete_model.py
Expand Up @@ -1043,12 +1043,7 @@ def fit(self, start_params=None, method='newton', maxiter=35,
method=method, maxiter=maxiter, full_output=full_output,
disp=disp, callback=callback, **kwargs)

if 'cov_type' in kwargs:
cov_kwds = kwargs.get('cov_kwds', {})
kwds = {'cov_type':kwargs['cov_type'], 'cov_kwds':cov_kwds}
else:
kwds = {}
discretefit = PoissonResults(self, cntfit, **kwds)
discretefit = PoissonResults(self, cntfit)
return PoissonResultsWrapper(discretefit)
fit.__doc__ = DiscreteModel.fit.__doc__

Expand Down Expand Up @@ -1463,19 +1458,16 @@ def fit(self, start_params=None, method='bfgs', maxiter=35,
full_output=full_output, callback=callback,
**kwargs)


if use_transparams and method not in ["newton", "ncg"]:
self._transparams = False
mlefit._results.params[-1] = np.exp(mlefit._results.params[-1])
# ensure cov_params are re-evaluated with updated params
delattr(mlefit._results, "cov_type")

gpfit = GeneralizedPoissonResults(self, mlefit._results)
gpfit = GeneralizedPoissonResults(self, mlefit._results,
cov_type=cov_type, use_t=use_t,
cov_kwds=cov_kwds)
result = GeneralizedPoissonResultsWrapper(gpfit)

if cov_kwds is None:
cov_kwds = {}

result._get_robustcov_results(cov_type=cov_type,
use_self=True, use_t=use_t, **cov_kwds)
return result

fit.__doc__ = DiscreteModel.fit.__doc__ + fit.__doc__
Expand Down Expand Up @@ -3214,11 +3206,6 @@ def fit(self, start_params=None, method='bfgs', maxiter=35,

nbinfit = NegativeBinomialResults(self, mlefit._results)
result = NegativeBinomialResultsWrapper(nbinfit)

if cov_kwds is None:
cov_kwds = {}
result._get_robustcov_results(cov_type=cov_type,
use_self=True, use_t=use_t, **cov_kwds)
return result

fit.__doc__ += DiscreteModel.fit.__doc__
Expand Down Expand Up @@ -3365,6 +3352,8 @@ def __init__(self, model, mlefit, cov_type='nonrobust', cov_kwds=None,
if cov_kwds is None:
cov_kwds = {}
from statsmodels.base.covtype import get_robustcov_results
# TODO: use self._get_robustcov_results? Only difference
# with base class is that base class passes use_t
get_robustcov_results(self, cov_type=cov_type, use_self=True,
**cov_kwds)

Expand Down

0 comments on commit f32994b

Please sign in to comment.