class_docstr: Class to contain results from likelihood models 
class_docstr_tok: ["Class","to","contain","results","from","likelihood","models"]
docstr: Compute an Fcontrast for a 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 contrast 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","Fcontrast","for","a","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","contrast","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 Fcontrast for a 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 contrast 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 contrasts should have shape[1] P=%d, "
              "but this has shape[1] %d"
              % (self.theta.shape[0], matrix.shape[1])
          )
      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
      ) * pos_recipr(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_resid,
          df_num=invcov.shape[0],
      )
  
imports: import numpy
  from nibabel.onetime import auto_attr
  from numpy.linalg import inv
  from scipy.stats import t
  from ...utils.matrices import pos_recipr
label_desc: Use image node_id 8 for calling the LikelihoodModelResults obj's underlying member method code with example usage: obj.Fcontrast(matrix, dispersion, invcov) and returns: FContrastResults