class_docstr: Multivariate kernel density estimator.
  
  This density estimator can handle univariate as well as multivariate data,
  including mixed continuous / ordered discrete / unordered discrete data.
  It also provides cross-validated bandwidth selection methods (least
  squares, maximum likelihood).
  
  Parameters
  ----------
  data : list of ndarrays or 2-D ndarray
      The training data for the Kernel Density Estimation, used to determine
      the bandwidth(s).  If a 2-D array, should be of shape
      (num_observations, num_variables).  If a list, each list element is a
      separate observation.
  var_type : str
      The type of the variables:
  
          - c : continuous
          - u : unordered (discrete)
          - o : ordered (discrete)
  
      The string should contain a type specifier for each variable, so for
      example ``var_type='ccuo'``.
  bw : array_like or str, optional
      If an array, it is a fixed user-specified bandwidth.  If a string,
      should be one of:
  
          - normal_reference: normal reference rule of thumb (default)
          - cv_ml: cross validation maximum likelihood
          - cv_ls: cross validation least squares
  
  defaults : EstimatorSettings instance, optional
      The default values for (efficient) bandwidth estimation.
  
  Attributes
  ----------
  bw : array_like
      The bandwidth parameters.
  
  See Also
  --------
  KDEMultivariateConditional
  
  Examples
  --------
  >>> import statsmodels.api as sm
  >>> nobs = 300
  >>> np.random.seed(1234)  # Seed random generator
  >>> c1 = np.random.normal(size=(nobs,1))
  >>> c2 = np.random.normal(2, 1, size=(nobs,1))
  
  Estimate a bivariate distribution and display the bandwidth found:
  
  >>> dens_u = sm.nonparametric.KDEMultivariate(data=[c1,c2],
  ...     var_type='cc', bw='normal_reference')
  >>> dens_u.bw
  array([ 0.39967419,  0.38423292])
class_docstr_tok: ["Multivariate","kernel","density","estimator",".","This","density","estimator","can","handle","univariate","as","well","as","multivariate","data",",","including","mixed","continuous","\/","ordered","discrete","\/","unordered","discrete","data",".","It","also","provides","cross-validated","bandwidth","selection","methods","(","least","squares",",","maximum","likelihood",")",".","Parameters","--","--","--","--","--","data",":","list","of","ndarrays","or","2-D","ndarray","The","training","data","for","the","Kernel","Density","Estimation",",","used","to","determine","the","bandwidth","(","s",")",".","If","a","2-D","array",",","should","be","of","shape","(","num_observations",",","num_variables",")",".","If","a","list",",","each","list","element","is","a","separate","observation",".","var_type",":","str","The","type","of","the","variables",":","-","c",":","continuous","-","u",":","unordered","(","discrete",")","-","o",":","ordered","(","discrete",")","The","string","should","contain","a","type","specifier","for","each","variable",",","so","for","example","``","var_type='ccuo","'","``",".","bw",":","array_like","or","str",",","optional","If","an","array",",","it","is","a","fixed","user-specified","bandwidth",".","If","a","string",",","should","be","one","of",":","-","normal_reference",":","normal","reference","rule","of","thumb","(","default",")","-","cv_ml",":","cross","validation","maximum","likelihood","-","cv_ls",":","cross","validation","least","squares","defaults",":","EstimatorSettings","instance",",","optional","The","default","values","for","(","efficient",")","bandwidth","estimation",".","Attributes","--","--","--","--","--","bw",":","array_like","The","bandwidth","parameters",".","See","Also","--","--","--","--","KDEMultivariateConditional","Examples","--","--","--","--",">",">",">","import","statsmodels.api","as","sm",">",">",">","nobs","=","300",">",">",">","np.random.seed","(","1234",")","#","Seed","random","generator",">",">",">","c1","=","np.random.normal","(","size=","(","nobs,1",")",")",">",">",">","c2","=","np.random.normal","(","2",",","1",",","size=","(","nobs,1",")",")","Estimate","a","bivariate","distribution","and","display","the","bandwidth","found",":",">",">",">","dens_u","=","sm.nonparametric.KDEMultivariate","(","data=","[","c1",",","c2","]",",","...","var_type='cc","'",",","bw='normal_reference","'",")",">",">",">","dens_u.bw","array","(","[","0.39967419",",","0.38423292","]",")"]
docstr: Returns the Integrated Mean Square Error for the unconditional KDE.
  
  Parameters
  ----------
  bw : array_like
      The bandwidth parameter(s).
  
  Returns
  -------
  CV : float
      The cross-validation objective function.
  
  Notes
  -----
  See p. 27 in [1]_ for details on how to handle the multivariate
  estimation with mixed data types see p.6 in [2]_.
  
  The formula for the cross-validation objective function is:
  
  .. math:: CV=\frac{1}{n^{2}}\sum_{i=1}^{n}\sum_{j=1}^{N}
      \bar{K}_{h}(X_{i},X_{j})-\frac{2}{n(n-1)}\sum_{i=1}^{n}
      \sum_{j=1,j\neq i}^{N}K_{h}(X_{i},X_{j})
  
  Where :math:`\bar{K}_{h}` is the multivariate product convolution
  kernel (consult [2]_ for mixed data types).
  
  References
  ----------
  .. [1] Racine, J., Li, Q. Nonparametric econometrics: theory and
          practice. Princeton University Press. (2007)
  .. [2] Racine, J., Li, Q. "Nonparametric Estimation of Distributions
          with Categorical and Continuous Data." Working Paper. (2000)
docstr_tok: ["Returns","the","Integrated","Mean","Square","Error","for","the","unconditional","KDE",".","Parameters","--","--","--","--","--","bw",":","array_like","The","bandwidth","parameter","(","s",")",".","Returns","--","--","--","-","CV",":","float","The","cross-validation","objective","function",".","Notes","--","--","-","See","p.","27","in","[","1","]","_","for","details","on","how","to","handle","the","multivariate","estimation","with","mixed","data","types","see","p.6","in","[","2","]","_",".","The","formula","for","the","cross-validation","objective","function","is",":","..","math",":",":","CV=\\frac","{","1","}","{","n^","{","2","}","}","\\sum_","{","i=1","}","^","{","n","}","\\sum_","{","j=1","}","^","{","N","}","\\bar","{","K","}","_","{","h","}","(","X_","{","i","}",",","X_","{","j","}",")","-\\frac","{","2","}","{","n","(","n-1",")","}","\\sum_","{","i=1","}","^","{","n","}","\\sum_","{","j=1",",","j\\neq","i","}","^","{","N","}","K_","{","h","}","(","X_","{","i","}",",","X_","{","j","}",")","Where",":","math",":","`","\\bar","{","K","}","_","{","h","}","`","is","the","multivariate","product","convolution","kernel","(","consult","[","2","]","_","for","mixed","data","types",")",".","References","--","--","--","--","--","..","[","1","]","Racine",",","J.",",","Li",",","Q.","Nonparametric","econometrics",":","theory","and","practice",".","Princeton","University","Press",".","(","2007",")","..","[","2","]","Racine",",","J.",",","Li",",","Q",".","``","Nonparametric","Estimation","of","Distributions","with","Categorical","and","Continuous","Data",".","''","Working","Paper",".","(","2000",")"]
code: def imse(self, bw):
      r"""
      Returns the Integrated Mean Square Error for the unconditional KDE.
  
      Parameters
      ----------
      bw : array_like
          The bandwidth parameter(s).
  
      Returns
      -------
      CV : float
          The cross-validation objective function.
  
      Notes
      -----
      See p. 27 in [1]_ for details on how to handle the multivariate
      estimation with mixed data types see p.6 in [2]_.
  
      The formula for the cross-validation objective function is:
  
      .. math:: CV=\frac{1}{n^{2}}\sum_{i=1}^{n}\sum_{j=1}^{N}
          \bar{K}_{h}(X_{i},X_{j})-\frac{2}{n(n-1)}\sum_{i=1}^{n}
          \sum_{j=1,j\neq i}^{N}K_{h}(X_{i},X_{j})
  
      Where :math:`\bar{K}_{h}` is the multivariate product convolution
      kernel (consult [2]_ for mixed data types).
  
      References
      ----------
      .. [1] Racine, J., Li, Q. Nonparametric econometrics: theory and
              practice. Princeton University Press. (2007)
      .. [2] Racine, J., Li, Q. "Nonparametric Estimation of Distributions
              with Categorical and Continuous Data." Working Paper. (2000)
      """
      # F = 0
      # for i in range(self.nobs):
      #    k_bar_sum = gpke(bw, data=-self.data,
      #                     data_predict=-self.data[i, :],
      #                     var_type=self.var_type,
      #                     ckertype='gauss_convolution',
      #                     okertype='wangryzin_convolution',
      #                     ukertype='aitchisonaitken_convolution')
      #    F += k_bar_sum
      ## there is a + because loo_likelihood returns the negative
      # return (F / self.nobs**2 + self.loo_likelihood(bw) * \
      #        2 / ((self.nobs) * (self.nobs - 1)))
  
      # The code below is equivalent to the commented-out code above.  It's
      # about 20% faster due to some code being moved outside the for-loops
      # and shared by gpke() and loo_likelihood().
      F = 0
      kertypes = dict(
          c=kernels.gaussian_convolution,
          o=kernels.wang_ryzin_convolution,
          u=kernels.aitchison_aitken_convolution,
      )
      nobs = self.nobs
      data = -self.data
      var_type = self.var_type
      ix_cont = np.array([c == "c" for c in var_type])
      _bw_cont_product = bw[ix_cont].prod()
      Kval = np.empty(data.shape)
      for i in range(nobs):
          for ii, vtype in enumerate(var_type):
              Kval[:, ii] = kertypes[vtype](
                  bw[ii], data[:, ii], data[i, ii]
              )
  
          dens = Kval.prod(axis=1) / _bw_cont_product
          k_bar_sum = dens.sum(axis=0)
          F += k_bar_sum  # sum of prod kernel over nobs
  
      kertypes = dict(
          c=kernels.gaussian,
          o=kernels.wang_ryzin,
          u=kernels.aitchison_aitken,
      )
      LOO = LeaveOneOut(self.data)
      L = 0  # leave-one-out likelihood
      Kval = np.empty((data.shape[0] - 1, data.shape[1]))
      for i, X_not_i in enumerate(LOO):
          for ii, vtype in enumerate(var_type):
              Kval[:, ii] = kertypes[vtype](
                  bw[ii], -X_not_i[:, ii], data[i, ii]
              )
          dens = Kval.prod(axis=1) / _bw_cont_product
          L += dens.sum(axis=0)
  
      # CV objective function, eq. (2.4) of Ref. [3]
      return F / nobs**2 - 2 * L / (nobs * (nobs - 1))
  
imports: import numpy
  from .None import kernels
  from ._kernel_base import GenericKDE, EstimatorSettings, gpke, LeaveOneOut, _adjust_shape
label_desc: Use image node_id 6 for calling the KDEMultivariate obj's underlying member method code with example usage: obj.imse(bw) and returns: unknown