code: def fit(self, data):
          
          data = atleast_3d(data)
  
          if self.delta == 0 or self.delta is None:
              # ordinary least squares
              x, y = self._construct_eqns(data)
          else:
              # regularized least squares (ridge regression)
              x, y = self._construct_eqns_rls(data)
  
          b, res, rank, s = sp.linalg.lstsq(x, y)
  
          self.coef = b.transpose()
  
          self.residuals = data - self.predict(data)
          self.rescov = sp.cov(cat_trials(self.residuals[:, :, self.p:]))
  
          return self
docs: Fit VAR model to data.
          
          Parameters
          ----------
          data : array, shape (trials, channels, samples) or (channels, samples)
              Epoched or continuous data set.
              
          Returns
          -------
          self : :class:`VAR`
              The :class:`VAR` object to facilitate method chaining (see usage
              example).