class_docstr: Class to contain results from likelihood models.
  
  This is the class in which things like AIC, BIC, llf
  can be implemented as methods, not computed in, say,
  the fit method of OLSModel.
class_docstr_tok: ["Class","to","contain","results","from","likelihood","models",".","This","is","the","class","in","which","things","like","AIC",",","BIC",",","llf","can","be","implemented","as","methods",",","not","computed","in",",","say",",","the","fit","method","of","OLSModel","."]
docstr: Compute an F contrast for a :term:`contrast` matrix ``matrix``.
  
  Here, ``matrix`` M is assumed to be non-singular. More precisely
  
  .. math::
  
      M pX pX' M'
  
  is assumed invertible. Here, :math:`pX` is the generalized inverse of
  the design matrix of the model.
  There can be problems in non-OLS models where
  the rank of the covariance of the noise is not full.
  
  See the contrasts module to see how to specify contrasts.
  In particular, the matrices from these contrasts will always be
  non-singular in the sense above.
  
  Parameters
  ----------
  matrix : 1D array-like
      Contrast matrix.
  
  dispersion : None or float, optional
      If None, use ``self.dispersion``.
  
  invcov : None or array, optional
      Known inverse of variance covariance matrix.
      If None, calculate this matrix.
  
  Returns
  -------
  f_res : ``FContrastResults`` instance
      with attributes F, df_den, df_num
  
  Notes
  -----
  For F contrasts, we now specify an effect and covariance.
docstr_tok: ["Compute","an","F","contrast","for","a",":","term",":","`","contrast","`","matrix","``","matrix","``",".","Here",",","``","matrix","``","M","is","assumed","to","be","non-singular",".","More","precisely","..","math",":",":","M","pX","pX","'","M'","is","assumed","invertible",".","Here",",",":","math",":","`","pX","`","is","the","generalized","inverse","of","the","design","matrix","of","the","model",".","There","can","be","problems","in","non-OLS","models","where","the","rank","of","the","covariance","of","the","noise","is","not","full",".","See","the","contrasts","module","to","see","how","to","specify","contrasts",".","In","particular",",","the","matrices","from","these","contrasts","will","always","be","non-singular","in","the","sense","above",".","Parameters","--","--","--","--","--","matrix",":","1D","array-like","Contrast","matrix",".","dispersion",":","None","or","float",",","optional","If","None",",","use","``","self.dispersion","``",".","invcov",":","None","or","array",",","optional","Known","inverse","of","variance","covariance","matrix",".","If","None",",","calculate","this","matrix",".","Returns","--","--","--","-","f_res",":","``","FContrastResults","``","instance","with","attributes","F",",","df_den",",","df_num","Notes","--","--","-","For","F","contrasts",",","we","now","specify","an","effect","and","covariance","."]
code: def Fcontrast(self, matrix, dispersion=None, invcov=None):
      """Compute an F contrast for a :term:`contrast` matrix ``matrix``.
  
      Here, ``matrix`` M is assumed to be non-singular. More precisely
  
      .. math::
  
          M pX pX' M'
  
      is assumed invertible. Here, :math:`pX` is the generalized inverse of
      the design matrix of the model.
      There can be problems in non-OLS models where
      the rank of the covariance of the noise is not full.
  
      See the contrasts module to see how to specify contrasts.
      In particular, the matrices from these contrasts will always be
      non-singular in the sense above.
  
      Parameters
      ----------
      matrix : 1D array-like
          Contrast matrix.
  
      dispersion : None or float, optional
          If None, use ``self.dispersion``.
  
      invcov : None or array, optional
          Known inverse of variance covariance matrix.
          If None, calculate this matrix.
  
      Returns
      -------
      f_res : ``FContrastResults`` instance
          with attributes F, df_den, df_num
  
      Notes
      -----
      For F contrasts, we now specify an effect and covariance.
  
      """
      matrix = np.asarray(matrix)
      # 1D vectors assumed to be row vector
      if matrix.ndim == 1:
          matrix = matrix[None]
      if matrix.shape[1] != self.theta.shape[0]:
          raise ValueError(
              f"F contrasts should have shape[1]={self.theta.shape[0]}, "
              f"but this has shape[1]={matrix.shape[1]}"
          )
      matrix = pad_contrast(
          con_val=matrix, theta=self.theta, stat_type="F"
      )
      ctheta = np.dot(matrix, self.theta)
      if matrix.ndim == 1:
          matrix = matrix.reshape((1, matrix.shape[0]))
      if dispersion is None:
          dispersion = self.dispersion
      q = matrix.shape[0]
      if invcov is None:
          invcov = inv(self.vcov(matrix=matrix, dispersion=1.0))
      F = np.add.reduce(
          np.dot(invcov, ctheta) * ctheta, 0
      ) * positive_reciprocal(q * dispersion)
      F = np.squeeze(F)
      return FContrastResults(
          effect=ctheta,
          covariance=self.vcov(
              matrix=matrix, dispersion=dispersion[np.newaxis]
          ),
          F=F,
          df_den=self.df_residuals,
          df_num=invcov.shape[0],
      )
  
imports: import numpy
  from nibabel.onetime import auto_attr
  from scipy.linalg import inv
  from scipy.stats import t
  from nilearn.glm._utils import pad_contrast, positive_reciprocal
label_desc: Use image node_id 6 for calling the LikelihoodModelResults obj's underlying member method code with example usage: obj.Fcontrast(matrix, dispersion, invcov) and returns: FContrastResults