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.
  
  whitened_design : ndarray
      This is the whitened design matrix.
      `design` == `whitened_design` 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_residuals : 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.
docstr: Return the value of the loglikelihood function at beta.
  
  Given the whitened design matrix, the loglikelihood is evaluated
  at the parameter vector, :term:`beta<Beta>`,
  for the dependent variable, Y
  and the nuisance parameter, sigma :footcite:t:`Greene2003`.
  
  Parameters
  ----------
  beta : ndarray
      The parameter estimates.  Must be of length ``df_model``.
  
  Y : ndarray
      The dependent variable
  
  nuisance : dict, optional
      A dict with key 'sigma', which is an optional estimate of sigma.
      If None, defaults to its maximum likelihood estimate
      (with beta fixed) as
      ``sum((Y - X*beta)**2) / n``, where n=Y.shape[0], X=self.design.
  
  Returns
  -------
  loglf : float
      The value of the loglikelihood function.
  
  Notes
  -----
  The log-Likelihood Function is defined as
  
  .. math::
  
      \ell(\beta,\sigma,Y)=
      -\frac{n}{2}\log(2\pi\sigma^2) - \|Y-X\beta\|^2/(2\sigma^2)
  
  The parameter :math:`\sigma` above is what is sometimes referred to
  as a nuisance parameter. That is, the likelihood is considered as a
  function of :math:`\beta`, but to evaluate it, a value of
  :math:`\sigma` is needed.
  
  If :math:`\sigma` is not provided,
  then its maximum likelihood estimate:
  
  .. math::
  
      \hat{\sigma}(\beta) = \frac{\text{SSE}(\beta)}{n}
  
  is plugged in. This likelihood is now a function of only :math:`\beta`
  and is technically referred to as a profile-likelihood.
  
  References
  ----------
  .. footbibliography::
docstr_tok: ["Return","the","value","of","the","loglikelihood","function","at","beta",".","Given","the","whitened","design","matrix",",","the","loglikelihood","is","evaluated","at","the","parameter","vector",",",":","term",":","`","beta","<","Beta",">","`",",","for","the","dependent","variable",",","Y","and","the","nuisance","parameter",",","sigma",":","footcite",":","t",":","`","Greene2003","`",".","Parameters","--","--","--","--","--","beta",":","ndarray","The","parameter","estimates",".","Must","be","of","length","``","df_model","``",".","Y",":","ndarray","The","dependent","variable","nuisance",":","dict",",","optional","A","dict","with","key","'sigma","'",",","which","is","an","optional","estimate","of","sigma",".","If","None",",","defaults","to","its","maximum","likelihood","estimate","(","with","beta","fixed",")","as","``","sum","(","(","Y","-","X","*","beta",")","*","*","2",")","\/","n","``",",","where","n=Y.shape","[","0","]",",","X=self.design",".","Returns","--","--","--","-","loglf",":","float","The","value","of","the","loglikelihood","function",".","Notes","--","--","-","The","log-Likelihood","Function","is","defined","as","..","math",":",":","\\ell","(","\\beta",",","\\sigma",",","Y",")","=","-\\frac","{","n","}","{","2","}","\\log","(","2\\pi\\sigma^2",")","-","\\|Y-X\\beta\\|^2\/","(","2\\sigma^2",")","The","parameter",":","math",":","`","\\sigma","`","above","is","what","is","sometimes","referred","to","as","a","nuisance","parameter",".","That","is",",","the","likelihood","is","considered","as","a","function","of",":","math",":","`","\\beta","`",",","but","to","evaluate","it",",","a","value","of",":","math",":","`","\\sigma","`","is","needed",".","If",":","math",":","`","\\sigma","`","is","not","provided",",","then","its","maximum","likelihood","estimate",":","..","math",":",":","\\hat","{","\\sigma","}","(","\\beta",")","=","\\frac","{","\\text","{","SSE","}","(","\\beta",")","}","{","n","}","is","plugged","in",".","This","likelihood","is","now","a","function","of","only",":","math",":","`","\\beta","`","and","is","technically","referred","to","as","a","profile-likelihood",".","References","--","--","--","--","--","..","footbibliography",":",":"]
code: def logL(self, beta, Y, nuisance=None):
      r"""Return the value of the loglikelihood function at beta.
  
      Given the whitened design matrix, the loglikelihood is evaluated
      at the parameter vector, :term:`beta<Beta>`,
      for the dependent variable, Y
      and the nuisance parameter, sigma :footcite:t:`Greene2003`.
  
      Parameters
      ----------
      beta : ndarray
          The parameter estimates.  Must be of length ``df_model``.
  
      Y : ndarray
          The dependent variable
  
      nuisance : dict, optional
          A dict with key 'sigma', which is an optional estimate of sigma.
          If None, defaults to its maximum likelihood estimate
          (with beta fixed) as
          ``sum((Y - X*beta)**2) / n``, where n=Y.shape[0], X=self.design.
  
      Returns
      -------
      loglf : float
          The value of the loglikelihood function.
  
      Notes
      -----
      The log-Likelihood Function is defined as
  
      .. math::
  
          \ell(\beta,\sigma,Y)=
          -\frac{n}{2}\log(2\pi\sigma^2) - \|Y-X\beta\|^2/(2\sigma^2)
  
      The parameter :math:`\sigma` above is what is sometimes referred to
      as a nuisance parameter. That is, the likelihood is considered as a
      function of :math:`\beta`, but to evaluate it, a value of
      :math:`\sigma` is needed.
  
      If :math:`\sigma` is not provided,
      then its maximum likelihood estimate:
  
      .. math::
  
          \hat{\sigma}(\beta) = \frac{\text{SSE}(\beta)}{n}
  
      is plugged in. This likelihood is now a function of only :math:`\beta`
      and is technically referred to as a profile-likelihood.
  
      References
      ----------
      .. footbibliography::
  
      """
      # This is overwriting an abstract method of LikelihoodModel
      X = self.whitened_design
      wY = self.whiten(Y)
      r = wY - np.dot(X, beta)
      n = self.df_total
      SSE = (r**2).sum(0)
      sigmasq = SSE / n if nuisance is None else nuisance["sigma"]
  
      loglf = -n / 2.0 * np.log(2 * np.pi * sigmasq) - SSE / (
          2 * sigmasq
      )
      return loglf
  
imports: import numpy
  import scipy.linalg
  from nibabel.onetime import auto_attr
  from numpy.linalg import matrix_rank
  from nilearn.glm._utils import positive_reciprocal
  from nilearn.glm.model import LikelihoodModelResults
label_desc: Use image node_id 3 for calling the OLSModel obj's underlying member method code with example usage: obj.logL(beta, Y, nuisance) and returns: loglf