class_docstr: Mixin class for Maximum Penalized Likelihood
  
  Parameters
  ----------
  args and kwds for the model super class
  penal : None or instance of Penalized function class
      If penal is None, then NonePenalty is used.
  pen_weight : float or None
      factor for weighting the penalization term.
      If None, then pen_weight is set to nobs.
  
  
  TODO: missing **kwds or explicit keywords
  
  TODO: do we adjust the inherited docstrings?
  We would need templating to add the penalization parameters
docstr: minimize negative penalized log-likelihood
  
  Parameters
  ----------
  method : None or str
      Method specifies the scipy optimizer as in nonlinear MLE models.
  trim : {bool, float}
      Default is False or None, which uses no trimming.
      If trim is True or a float, then small parameters are set to zero.
      If True, then a default threshold is used. If trim is a float, then
      it will be used as threshold.
      The default threshold is currently 1e-4, but it will change in
      future and become penalty function dependent.
  kwds : extra keyword arguments
      This keyword arguments are treated in the same way as in the
      fit method of the underlying model class.
      Specifically, additional optimizer keywords and cov_type related
      keywords can be added.
docstr_tok: ["minimize","negative","penalized","log-likelihood","Parameters","--","--","--","--","--","method",":","None","or","str","Method","specifies","the","scipy","optimizer","as","in","nonlinear","MLE","models",".","trim",":","{","bool",",","float","}","Default","is","False","or","None",",","which","uses","no","trimming",".","If","trim","is","True","or","a","float",",","then","small","parameters","are","set","to","zero",".","If","True",",","then","a","default","threshold","is","used",".","If","trim","is","a","float",",","then","it","will","be","used","as","threshold",".","The","default","threshold","is","currently","1e-4",",","but","it","will","change","in","future","and","become","penalty","function","dependent",".","kwds",":","extra","keyword","arguments","This","keyword","arguments","are","treated","in","the","same","way","as","in","the","fit","method","of","the","underlying","model","class",".","Specifically",",","additional","optimizer","keywords","and","cov_type","related","keywords","can","be","added","."]
code: def fit(self, method=None, trim=None, **kwds):
      """minimize negative penalized log-likelihood
  
      Parameters
      ----------
      method : None or str
          Method specifies the scipy optimizer as in nonlinear MLE models.
      trim : {bool, float}
          Default is False or None, which uses no trimming.
          If trim is True or a float, then small parameters are set to zero.
          If True, then a default threshold is used. If trim is a float, then
          it will be used as threshold.
          The default threshold is currently 1e-4, but it will change in
          future and become penalty function dependent.
      kwds : extra keyword arguments
          This keyword arguments are treated in the same way as in the
          fit method of the underlying model class.
          Specifically, additional optimizer keywords and cov_type related
          keywords can be added.
      """
      # If method is None, then we choose a default method ourselves
  
      # TODO: temporary hack, need extra fit kwds
      # we need to rule out fit methods in a model that will not work with
      # penalization
      from statsmodels.gam.generalized_additive_model import GLMGam
      from statsmodels.genmod.generalized_linear_model import GLM
  
      # Only for fit methods supporting max_start_irls
      if isinstance(self, (GLM, GLMGam)):
          kwds.update({"max_start_irls": 0})
  
      # currently we use `bfgs` by default
      if method is None:
          method = "bfgs"
  
      if trim is None:
          trim = False
  
      res = super().fit(method=method, **kwds)
  
      if trim is False:
          # note boolean check for "is False", not "False_like"
          return res
      else:
          if trim is True:
              trim = 1e-4  # trim threshold
          # TODO: make it penal function dependent
          # temporary standin, only checked for Poisson and GLM,
          # and is computationally inefficient
          drop_index = np.nonzero(np.abs(res.params) < trim)[0]
          keep_index = np.nonzero(np.abs(res.params) > trim)[0]
  
          if drop_index.any():
              # TODO: do we need to add results attributes?
              res_aux = self._fit_zeros(keep_index, **kwds)
              return res_aux
          else:
              return res
  
file_path: statsmodels/statsmodels/base/_penalized.py
imports: import numpy
  from ._penalties import NonePenalty
  from statsmodels.tools.numdiff import approx_fprime_cs, approx_fprime
label_desc: Use image node_id 10 for calling the PenalizedMixin obj's underlying member method code with example usage: obj.fit(method, trim) and returns: res, res_aux, res