class_docstr: Dimension reduction for covariance matrices (CORE).
  
  Parameters
  ----------
  endog : array_like
      The dependent variable, treated as group labels
  exog : array_like
      The independent variables.
  dim : int
      The dimension of the subspace onto which the covariance
      matrices are projected.
  
  Returns
  -------
  A model instance.  Call `fit` on the model instance to obtain
  a results instance, which contains the fitted model parameters.
  
  Notes
  -----
  This is a likelihood-based dimension reduction procedure based
  on Wishart models for sample covariance matrices.  The goal
  is to find a projection matrix P so that C_i | P'C_iP and
  C_j | P'C_jP are equal in distribution for all i, j, where
  the C_i are the within-group covariance matrices.
  
  The model and methodology are as described in Cook and Forzani.
  The optimization method follows Edelman et. al.
  
  References
  ----------
  DR Cook, L Forzani (2008).  Covariance reducing models: an alternative
  to spectral modeling of covariance matrices.  Biometrika 95:4.
  
  A Edelman, TA Arias, ST Smith (1998).  The geometry of algorithms with
  orthogonality constraints. SIAM J Matrix Anal Appl.
  http://math.mit.edu/~edelman/publications/geometry_of_algorithms.pdf
class_docstr_tok: ["Dimension","reduction","for","covariance","matrices","(","CORE",")",".","Parameters","--","--","--","--","--","endog",":","array_like","The","dependent","variable",",","treated","as","group","labels","exog",":","array_like","The","independent","variables",".","dim",":","int","The","dimension","of","the","subspace","onto","which","the","covariance","matrices","are","projected",".","Returns","--","--","--","-","A","model","instance",".","Call","`","fit","`","on","the","model","instance","to","obtain","a","results","instance",",","which","contains","the","fitted","model","parameters",".","Notes","--","--","-","This","is","a","likelihood-based","dimension","reduction","procedure","based","on","Wishart","models","for","sample","covariance","matrices",".","The","goal","is","to","find","a","projection","matrix","P","so","that","C_i","|","P'C_iP","and","C_j","|","P'C_jP","are","equal","in","distribution","for","all","i",",","j",",","where","the","C_i","are","the","within-group","covariance","matrices",".","The","model","and","methodology","are","as","described","in","Cook","and","Forzani",".","The","optimization","method","follows","Edelman","et",".","al",".","References","--","--","--","--","--","DR","Cook",",","L","Forzani","(","2008",")",".","Covariance","reducing","models",":","an","alternative","to","spectral","modeling","of","covariance","matrices",".","Biometrika","95:4",".","A","Edelman",",","TA","Arias",",","ST","Smith","(","1998",")",".","The","geometry","of","algorithms","with","orthogonality","constraints",".","SIAM","J","Matrix","Anal","Appl",".","http",":","\/\/math.mit.edu\/~edelman\/publications\/geometry_of_algorithms.pdf"]
code: def __init__(self, endog, exog, dim):
      super().__init__(endog, exog)
  
      covs, ns = [], []
      df = pd.DataFrame(self.exog, index=self.endog)
      for _, v in df.groupby(df.index):
          covs.append(v.cov().values)
          ns.append(v.shape[0])
  
      self.nobs = len(endog)
  
      # The marginal covariance
      covm = 0
      for i, _ in enumerate(covs):
          covm += covs[i] * ns[i]
      covm /= self.nobs
      self.covm = covm
  
      self.covs = covs
      self.ns = ns
      self.dim = dim
  
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 1 to create a new CovarianceReduction object from inherited base classes: _DimReductionRegression with example: obj = CovarianceReduction(endog, exog, dim)