class_docstr: Todo:
  check treatment of const, make it optional ?
      add hasconst (0 or 1), needed when selecting nfact+hasconst
  options are arguments in calc_factors, should be more public instead
  cross-validation is slow for large number of observations
docstr: get factor decomposition of exogenous variables
  
  This uses principal component analysis to obtain the factors. The number
  of factors kept is the maximum that will be considered in the regression.
code: def calc_factors(self, x=None, keepdim=0, addconst=True):
      """get factor decomposition of exogenous variables
  
      This uses principal component analysis to obtain the factors. The number
      of factors kept is the maximum that will be considered in the regression.
      """
      if x is None:
          x = self.exog
      else:
          x = np.asarray(x)
      xred, fact, evals, evecs = pca(x, keepdim=keepdim, normalize=1)
      self.exog_reduced = xred
      # self.factors = fact
      if addconst:
          self.factors = sm.add_constant(fact, prepend=True)
          self.hasconst = 1  # needs to be int
      else:
          self.factors = fact
          self.hasconst = 0  # needs to be int
  
      self.evals = evals
      self.evecs = evecs
  
file_path: statsmodels/statsmodels/sandbox/datarich/factormodels.py
imports: import numpy
  import statsmodels.api
  from statsmodels.sandbox.tools import pca
  from statsmodels.sandbox.tools.cross_val import LeaveOneOut
label_desc: Use image node_id 2 for calling the FactorModelUnivariate obj's underlying member method code with example usage: obj.calc_factors(x, keepdim, addconst) without return types