class_docstr: Canonical correlation analysis using singular value decomposition
  
  For matrices exog=x and endog=y, find projections x_cancoef and y_cancoef
  such that:
  
      x1 = x * x_cancoef, x1' * x1 is identity matrix
      y1 = y * y_cancoef, y1' * y1 is identity matrix
  
  and the correlation between x1 and y1 is maximized.
  
  Attributes
  ----------
  endog : ndarray
      See Parameters.
  exog : ndarray
      See Parameters.
  cancorr : ndarray
      The canonical correlation values
  y_cancoef : ndarray
      The canonical coefficients for endog
  x_cancoef : ndarray
      The canonical coefficients for exog
  
  References
  ----------
  .. [*] http://numerical.recipes/whp/notes/CanonCorrBySVD.pdf
  .. [*] http://www.csun.edu/~ata20315/psy524/docs/Psy524%20Lecture%208%20CC.pdf
  .. [*] http://www.mathematica-journal.com/2014/06/canonical-correlation-analysis/
docstr: Fit the model
  
  A ValueError is raised if there are singular values smaller than the
  tolerance. The treatment of singular arrays might change in future.
  
  Parameters
  ----------
  tolerance : float
      eigenvalue tolerance, values smaller than which is considered 0
docstr_tok: ["Fit","the","model","A","ValueError","is","raised","if","there","are","singular","values","smaller","than","the","tolerance",".","The","treatment","of","singular","arrays","might","change","in","future",".","Parameters","--","--","--","--","--","tolerance",":","float","eigenvalue","tolerance",",","values","smaller","than","which","is","considered","0"]
code: def _fit(self, tolerance=1e-8):
      """Fit the model
  
      A ValueError is raised if there are singular values smaller than the
      tolerance. The treatment of singular arrays might change in future.
  
      Parameters
      ----------
      tolerance : float
          eigenvalue tolerance, values smaller than which is considered 0
      """
      nobs, k_yvar = self.endog.shape
      nobs, k_xvar = self.exog.shape
      k = np.min([k_yvar, k_xvar])
  
      x = np.array(self.exog)
      x = x - x.mean(0)
      y = np.array(self.endog)
      y = y - y.mean(0)
  
      ux, sx, vx = svd(x, 0)
      # vx_ds = vx.T divided by sx
      vx_ds = vx.T
      mask = sx > tolerance
      if mask.sum() < len(mask):
          raise ValueError("exog is collinear.")
      vx_ds[:, mask] /= sx[mask]
      uy, sy, vy = svd(y, 0)
      # vy_ds = vy.T divided by sy
      vy_ds = vy.T
      mask = sy > tolerance
      if mask.sum() < len(mask):
          raise ValueError("endog is collinear.")
      vy_ds[:, mask] /= sy[mask]
      u, s, v = svd(ux.T.dot(uy), 0)
  
      # Correct any roundoff
      self.cancorr = np.array(
          [max(0, min(s[i], 1)) for i in range(len(s))]
      )
  
      self.x_cancoef = vx_ds.dot(u[:, :k])
      self.y_cancoef = vy_ds.dot(v.T[:, :k])
  
file_path: statsmodels/statsmodels/multivariate/cancorr.py
imports: import numpy
  from numpy.linalg import svd
  import scipy
  import pandas
  from statsmodels.base.model import Model
  from statsmodels.iolib import summary2
  from .multivariate_ols import multivariate_stats
label_desc: Use image node_id 2 for calling the CanCorr obj's underlying member method code with example usage: obj._fit(tolerance) without return types