class_docstr: Sliced Inverse Regression (SIR)
  
  Parameters
  ----------
  endog : array_like (1d)
      The dependent variable
  exog : array_like (2d)
      The covariates
  
  References
  ----------
  KC Li (1991).  Sliced inverse regression for dimension reduction.
  JASA 86, 316-342.
class_docstr_tok: ["Sliced","Inverse","Regression","(","SIR",")","Parameters","--","--","--","--","--","endog",":","array_like","(","1d",")","The","dependent","variable","exog",":","array_like","(","2d",")","The","covariates","References","--","--","--","--","--","KC","Li","(","1991",")",".","Sliced","inverse","regression","for","dimension","reduction",".","JASA","86",",","316-342","."]
docstr: Estimate the EDR space using regularized SIR.
  
  Parameters
  ----------
  ndim : int
      The number of EDR directions to estimate
  pen_mat : array_like
      A 2d array such that the squared Frobenius norm of
      `dot(pen_mat, dirs)`` is added to the objective function,
      where `dirs` is an orthogonal array whose columns span
      the estimated EDR space.
  slice_n : int, optional
      Target number of observations per slice
  maxiter :int
      The maximum number of iterations for estimating the EDR
      space.
  gtol : float
      If the norm of the gradient of the objective function
      falls below this value, the algorithm has converged.
  
  Returns
  -------
  A results class instance.
  
  Notes
  -----
  If each row of `exog` can be viewed as containing the values of a
  function evaluated at equally-spaced locations, then setting the
  rows of `pen_mat` to [[1, -2, 1, ...], [0, 1, -2, 1, ..], ...]
  will give smooth EDR coefficients.  This is a form of "functional
  SIR" using the squared second derivative as a penalty.
  
  References
  ----------
  L. Ferre, A.F. Yao (2003).  Functional sliced inverse regression
  analysis.  Statistics: a journal of theoretical and applied
  statistics 37(6) 475-488.
docstr_tok: ["Estimate","the","EDR","space","using","regularized","SIR",".","Parameters","--","--","--","--","--","ndim",":","int","The","number","of","EDR","directions","to","estimate","pen_mat",":","array_like","A","2d","array","such","that","the","squared","Frobenius","norm","of","`","dot","(","pen_mat",",","dirs",")","``","is","added","to","the","objective","function",",","where","`","dirs","`","is","an","orthogonal","array","whose","columns","span","the","estimated","EDR","space",".","slice_n",":","int",",","optional","Target","number","of","observations","per","slice","maxiter",":","int","The","maximum","number","of","iterations","for","estimating","the","EDR","space",".","gtol",":","float","If","the","norm","of","the","gradient","of","the","objective","function","falls","below","this","value",",","the","algorithm","has","converged",".","Returns","--","--","--","-","A","results","class","instance",".","Notes","--","--","-","If","each","row","of","`","exog","`","can","be","viewed","as","containing","the","values","of","a","function","evaluated","at","equally-spaced","locations",",","then","setting","the","rows","of","`","pen_mat","`","to","[","[","1",",","-2",",","1",",","...","]",",","[","0",",","1",",","-2",",","1",",","..","]",",","...","]","will","give","smooth","EDR","coefficients",".","This","is","a","form","of","``","functional","SIR","''","using","the","squared","second","derivative","as","a","penalty",".","References","--","--","--","--","--","L.","Ferre",",","A.F",".","Yao","(","2003",")",".","Functional","sliced","inverse","regression","analysis",".","Statistics",":","a","journal","of","theoretical","and","applied","statistics","37","(","6",")","475-488","."]
code: def fit_regularized(
      self,
      ndim=1,
      pen_mat=None,
      slice_n=20,
      maxiter=100,
      gtol=1e-3,
      **kwargs,
  ):
      """
      Estimate the EDR space using regularized SIR.
  
      Parameters
      ----------
      ndim : int
          The number of EDR directions to estimate
      pen_mat : array_like
          A 2d array such that the squared Frobenius norm of
          `dot(pen_mat, dirs)`` is added to the objective function,
          where `dirs` is an orthogonal array whose columns span
          the estimated EDR space.
      slice_n : int, optional
          Target number of observations per slice
      maxiter :int
          The maximum number of iterations for estimating the EDR
          space.
      gtol : float
          If the norm of the gradient of the objective function
          falls below this value, the algorithm has converged.
  
      Returns
      -------
      A results class instance.
  
      Notes
      -----
      If each row of `exog` can be viewed as containing the values of a
      function evaluated at equally-spaced locations, then setting the
      rows of `pen_mat` to [[1, -2, 1, ...], [0, 1, -2, 1, ..], ...]
      will give smooth EDR coefficients.  This is a form of "functional
      SIR" using the squared second derivative as a penalty.
  
      References
      ----------
      L. Ferre, A.F. Yao (2003).  Functional sliced inverse regression
      analysis.  Statistics: a journal of theoretical and applied
      statistics 37(6) 475-488.
      """
  
      if len(kwargs) > 0:
          msg = "SIR.fit_regularized does not take keyword arguments"
          warnings.warn(msg)
  
      if pen_mat is None:
          raise ValueError("pen_mat is a required argument")
  
      start_params = kwargs.get("start_params", None)
  
      # Sample size per slice
      slice_n = kwargs.get("slice_n", 20)
  
      # Number of slices
      n_slice = self.exog.shape[0] // slice_n
  
      # Sort the data by endog
      ii = np.argsort(self.endog)
      x = self.exog[ii, :]
      x -= x.mean(0)
  
      covx = np.cov(x.T)
  
      # Split the data into slices
      split_exog = np.array_split(x, n_slice)
  
      mn = [z.mean(0) for z in split_exog]
      n = [z.shape[0] for z in split_exog]
      mn = np.asarray(mn)
      n = np.asarray(n)
      self._slice_props = n / n.sum()
      self.ndim = ndim
      self.k_vars = covx.shape[0]
      self.pen_mat = pen_mat
      self._covx = covx
      self.n_slice = n_slice
      self._slice_means = mn
  
      if start_params is None:
          params = np.zeros((self.k_vars, ndim))
          params[0:ndim, 0:ndim] = np.eye(ndim)
          params = params
      else:
          if start_params.shape[1] != ndim:
              msg = "Shape of start_params is not compatible with ndim"
              raise ValueError(msg)
          params = start_params
  
      params, _, cnvrg = _grass_opt(
          params,
          self._regularized_objective,
          self._regularized_grad,
          maxiter,
          gtol,
      )
  
      if not cnvrg:
          g = self._regularized_grad(params.ravel())
          gn = np.sqrt(np.dot(g, g))
          msg = "SIR.fit_regularized did not converge, |g|=%f" % gn
          warnings.warn(msg)
  
      results = DimReductionResults(self, params, eigs=None)
      return DimReductionResultsWrapper(results)
  
imports: import warnings
  import numpy
  import pandas
  from statsmodels.base import model
  import statsmodels.base.wrapper
  from statsmodels.tools.sm_exceptions import ConvergenceWarning
label_desc: Use image node_id 4 for calling the SlicedInverseReg obj's underlying member method code with example usage: obj.fit_regularized(ndim, pen_mat, slice_n, maxiter, gtol) and returns: DimReductionResultsWrapper