class_docstr: Class to handle multiple one-sample mixed effects models
      
docstr: Launches the EM algorithm to estimate self
  
  Parameters
  ----------
  Y, array of shape (n_samples, n_tests) or (n_samples)
        the estimated effects
  V1, array of shape (n_samples, n_tests) or (n_samples)
           first-level variance
  
  Returns
  -------
  self
docstr_tok: ["Launches","the","EM","algorithm","to","estimate","self","Parameters","--","--","--","--","--","Y",",","array","of","shape","(","n_samples",",","n_tests",")","or","(","n_samples",")","the","estimated","effects","V1",",","array","of","shape","(","n_samples",",","n_tests",")","or","(","n_samples",")","first-level","variance","Returns","--","--","--","-","self"]
code: def fit(self, Y, V1):
      """Launches the EM algorithm to estimate self
  
      Parameters
      ----------
      Y, array of shape (n_samples, n_tests) or (n_samples)
            the estimated effects
      V1, array of shape (n_samples, n_tests) or (n_samples)
               first-level variance
  
      Returns
      -------
      self
      """
      # Basic data checks
      if self.X.shape[0] != Y.shape[0]:
          raise ValueError("X and Y must have the same numbers of rows")
      Y, V1 = check_arrays(Y, V1)
      self.beta_ = np.dot(self.pinv_X, Y)
      self.Y_ = np.dot(self.X, self.beta_)
      self.V2 = np.mean((Y - self.Y_) ** 2, 0)
  
      if self.verbose:
          log_like_init = self.log_like(Y, V1)
          print("Average log-likelihood: ", log_like_init.mean())
  
      for i in range(self.n_iter):
          self._one_step(Y, V1)
  
          if self.verbose:
              log_like_ = self.log_like(Y, V1)
              if (log_like_ < (log_like_init - EPS)).any():
                  raise ValueError("The log-likelihood cannot decrease")
              log_like_init = log_like_
              print(
                  "Iteration %d, average log-likelihood: %f"
                  % (i, log_like_.mean())
              )
      return self
  
file_path: nipy/nipy/algorithms/statistics/mixed_effects_stat.py
imports: import numpy
label_desc: Use image node_id 6 for calling the MixedEffectsModel obj's underlying member method code with example usage: obj.fit(Y, V1) and returns: self