'Fits a generalized linear model for a given family.
Parameters
start_params : array-like, optional
Initial guess of the solution for the loglikelihood maximization.
The default is family-specific and is given by the
``family.starting_mu(endog)``. If start_params is given then the
initial mean will be calculated as ``np.dot(exog, start_params)``.
maxiter : int, optional
Default is 100.
method : string
Default is \'IRLS\' for iteratively reweighted least squares.
Otherwise gradient optimization is used.
tol : float
Convergence tolerance.  Default is 1e-8.
scale : string or float, optional
`scale` can be \'X2\', \'dev\', or a float
The default value is None, which uses `X2` for Gamma, Gaussian,
and Inverse Gaussian.
`X2` is Pearson\'s chi-square divided by `df_resid`.
The default is 1 for the Binomial and Poisson families.
`dev` is the deviance divided by df_resid
cov_type : string
The type of parameter estimate covariance matrix to compute.
cov_kwds : dict-like
Extra arguments for calculating the covariance of the parameter
estimates.
use_t : bool
If True, the Student t-distribution is used for inference.
full_output : bool, optional
Set to True to have all available output in the Results object\'s
mle_retvals attribute. The output is dependent on the solver.
See LikelihoodModelResults notes section for more information.
Not used if methhod is IRLS.
disp : bool, optional
Set to True to print convergence messages.  Not used if method is
IRLS.
max_start_irls : int
The number of IRLS iterations used to obtain starting
values for gradient optimization.  Only relevant if
`method` is set to something other than \'IRLS\'.
If IRLS fitting used, the following additional parameters are
available:
atol : float, optional
The absolute tolerance criterion that must be satisfied. Defaults
to ``tol``. Convergence is attained when:
:math:`rtol * prior + atol > abs(current - prior)`
rtol : float, optional
The relative tolerance criterion that must be satisfied. Defaults
to 0 which means ``rtol`` is not used. Convergence is attained
when:
:math:`rtol * prior + atol > abs(current - prior)`
tol_criterion : str, optional
Defaults to ``\'deviance\'``. Can optionally be ``\'params\'``.
If a scipy optimizer is used, the following additional parameter is
available:
optim_hessian : {\'eim\', \'oim\'}, optional
When \'oim\', the default, the observed Hessian is used in fitting.
\'eim\' is the expected Hessian. This may provide more stable fits,
but adds assumption that the Hessian is correctly specified.'

def fit(self, start_params=None, maxiter=100, method='IRLS', tol=1e-08, scale=None, cov_type='nonrobust', cov_kwds=None, use_t=None, full_output=True, disp=False, max_start_irls=3, **kwargs):

    self.scaletype = scale
    if (method.lower() == 'irls'):
        return self._fit_irls(start_params=start_params, maxiter=maxiter, tol=tol, scale=scale, cov_type=cov_type, cov_kwds=cov_kwds, use_t=use_t, **kwargs)
    else:
        self._optim_hessian = kwargs.get('optim_hessian')
        fit_ = self._fit_gradient(start_params=start_params, method=method, maxiter=maxiter, tol=tol, scale=scale, full_output=full_output, disp=disp, cov_type=cov_type, cov_kwds=cov_kwds, use_t=use_t, max_start_irls=max_start_irls, **kwargs)
        self._optim_hessian = None
        return fit_
