class_docstr: A simple ordinary least squares model.
  
  Parameters
  ----------
  design : array-like
      This is your design matrix.  Data are assumed to be column ordered with
      observations in rows.
  
  Methods
  -------
  model.__init___(design)
  model.logL(b=self.beta, Y)
  
  Attributes
  ----------
  design : ndarray
      This is the design, or X, matrix.
  wdesign : ndarray
      This is the whitened design matrix.  `design` == `wdesign` by default
      for the OLSModel, though models that inherit from the OLSModel will
      whiten the design.
  calc_beta : ndarray
      This is the Moore-Penrose pseudoinverse of the whitened design matrix.
  normalized_cov_beta : ndarray
      ``np.dot(calc_beta, calc_beta.T)``
  df_resid : scalar
      Degrees of freedom of the residuals.  Number of observations less the
      rank of the design.
  df_model : scalar
      Degrees of freedome of the model.  The rank of the design.
  
  Examples
  --------
  >>> from nipy.algorithms.statistics.api import Term, Formula
  >>> data = np.rec.fromarrays(([1,3,4,5,2,3,4], range(1,8)),
  ...                          names=('Y', 'X'))
  >>> f = Formula([Term("X"), 1])
  >>> dmtx = f.design(data, return_float=True)
  >>> model = OLSModel(dmtx)
  >>> results = model.fit(data['Y'])
  >>> results.theta
  array([ 0.25      ,  2.14285714])
  >>> results.t()
  array([ 0.98019606,  1.87867287])
  >>> print(results.Tcontrast([0,1]))  #doctest: +FLOAT_CMP
  <T contrast: effect=2.14285714286, sd=1.14062281591, t=1.87867287326,
  df_den=5>
  >>> print(results.Fcontrast(np.eye(2)))  #doctest: +FLOAT_CMP
  <F contrast: F=19.4607843137, df_den=5, df_num=2>
class_docstr_tok: ["A","simple","ordinary","least","squares","model",".","Parameters","--","--","--","--","--","design",":","array-like","This","is","your","design","matrix",".","Data","are","assumed","to","be","column","ordered","with","observations","in","rows",".","Methods","--","--","--","-","model.__init___","(","design",")","model.logL","(","b=self.beta",",","Y",")","Attributes","--","--","--","--","--","design",":","ndarray","This","is","the","design",",","or","X",",","matrix",".","wdesign",":","ndarray","This","is","the","whitened","design","matrix",".","`","design","`","==","`","wdesign","`","by","default","for","the","OLSModel",",","though","models","that","inherit","from","the","OLSModel","will","whiten","the","design",".","calc_beta",":","ndarray","This","is","the","Moore-Penrose","pseudoinverse","of","the","whitened","design","matrix",".","normalized_cov_beta",":","ndarray","``","np.dot","(","calc_beta",",","calc_beta.T",")","``","df_resid",":","scalar","Degrees","of","freedom","of","the","residuals",".","Number","of","observations","less","the","rank","of","the","design",".","df_model",":","scalar","Degrees","of","freedome","of","the","model",".","The","rank","of","the","design",".","Examples","--","--","--","--",">",">",">","from","nipy.algorithms.statistics.api","import","Term",",","Formula",">",">",">","data","=","np.rec.fromarrays","(","(","[","1,3,4,5,2,3,4","]",",","range","(","1,8",")",")",",","...","names=","(","'","Y","'",",","'","X","'",")",")",">",">",">","f","=","Formula","(","[","Term","(","``","X","''",")",",","1","]",")",">",">",">","dmtx","=","f.design","(","data",",","return_float=True",")",">",">",">","model","=","OLSModel","(","dmtx",")",">",">",">","results","=","model.fit","(","data","[","'","Y","'","]",")",">",">",">","results.theta","array","(","[","0.25",",","2.14285714","]",")",">",">",">","results.t","(",")","array","(","[","0.98019606",",","1.87867287","]",")",">",">",">","print","(","results.Tcontrast","(","[","0,1","]",")",")","#","doctest",":","+FLOAT_CMP","<","T","contrast",":","effect=2.14285714286",",","sd=1.14062281591",",","t=1.87867287326",",","df_den=5",">",">",">",">","print","(","results.Fcontrast","(","np.eye","(","2",")",")",")","#","doctest",":","+FLOAT_CMP","<","F","contrast",":","F=19.4607843137",",","df_den=5",",","df_num=2",">"]
docstr: Fit model to data `Y`
  
  Full fit of the model including estimate of covariance matrix,
  (whitened) residuals and scale.
  
  Parameters
  ----------
  Y : array-like
      The dependent variable for the Least Squares problem.
  
  Returns
  -------
  fit : RegressionResults
code: def fit(self, Y):
      """Fit model to data `Y`
  
      Full fit of the model including estimate of covariance matrix,
      (whitened) residuals and scale.
  
      Parameters
      ----------
      Y : array-like
          The dependent variable for the Least Squares problem.
  
      Returns
      -------
      fit : RegressionResults
      """
      # Other estimates of the covariance matrix for a heteroscedastic
      # regression model can be implemented in WLSmodel. (Weighted least
      # squares models assume covariance is diagonal, i.e. heteroscedastic).
      wY = self.whiten(Y)
      beta = np.dot(self.calc_beta, wY)
      wresid = wY - np.dot(self.wdesign, beta)
      dispersion = np.sum(wresid**2, 0) / (
          self.wdesign.shape[0] - self.wdesign.shape[1]
      )
      lfit = RegressionResults(
          beta,
          Y,
          self,
          wY,
          wresid,
          dispersion=dispersion,
          cov=self.normalized_cov_beta,
      )
      return lfit
  
imports: import warnings
  import numpy
  import numpy.linalg
  import scipy.linalg
  from nibabel.onetime import auto_attr
  from scipy import stats
  from nipy.algorithms.utils.matrices import matrix_rank, pos_recipr
  from .model import LikelihoodModel, LikelihoodModelResults
label_desc: Use image node_id 9 for calling the OLSModel obj's underlying member method code with example usage: obj.fit(Y) and returns: lfit