class_docstr: This class is used to construct contrast matrices in regression models.
  
  They are specified by a (term, design) pair.  The term, T, is a linear
  combination of columns of the design matrix. The matrix attribute of
  Contrast is a contrast matrix C so that
  
  colspan(dot(D, C)) = colspan(dot(D, dot(pinv(D), T)))
  
  where pinv(D) is the generalized inverse of D. Further, the matrix
  
  Tnew = dot(C, D)
  
  is full rank. The rank attribute is the rank of
  
  dot(D, dot(pinv(D), T))
  
  In a regression model, the contrast tests that E(dot(Tnew, Y)) = 0
  for each column of Tnew.
  
  Parameters
  ----------
  term : array_like
  design : array_like
  
  Attributes
  ----------
  contrast_matrix
  
  Examples
  --------
  >>> import statsmodels.api as sm
  >>> from statsmodels.stats.contrast import Contrast
  >>> import numpy as np
  >>> np.random.seed(54321)
  >>> X = np.random.standard_normal((40,10))
  # Get a contrast
  >>> new_term = np.column_stack((X[:,0], X[:,2]))
  >>> c = Contrast(new_term, X)
  >>> test = [[1] + [0]*9, [0]*2 + [1] + [0]*7]
  >>> np.allclose(c.contrast_matrix, test)
  True
  
  Get another contrast
  
  >>> P = np.dot(X, np.linalg.pinv(X))
  >>> resid = np.identity(40) - P
  >>> noise = np.dot(resid,np.random.standard_normal((40,5)))
  >>> new_term2 = np.column_stack((noise,X[:,2]))
  >>> c2 = Contrast(new_term2, X)
  >>> print(c2.contrast_matrix)
  [ -1.26424750e-16   8.59467391e-17   1.56384718e-01  -2.60875560e-17
  -7.77260726e-17  -8.41929574e-18  -7.36359622e-17  -1.39760860e-16
  1.82976904e-16  -3.75277947e-18]
  
  Get another contrast
  
  >>> zero = np.zeros((40,))
  >>> new_term3 = np.column_stack((zero,X[:,2]))
  >>> c3 = Contrast(new_term3, X)
  >>> test2 = [0]*2 + [1] + [0]*7
  >>> np.allclose(c3.contrast_matrix, test2)
  True
class_docstr_tok: ["This","class","is","used","to","construct","contrast","matrices","in","regression","models",".","They","are","specified","by","a","(","term",",","design",")","pair",".","The","term",",","T",",","is","a","linear","combination","of","columns","of","the","design","matrix",".","The","matrix","attribute","of","Contrast","is","a","contrast","matrix","C","so","that","colspan","(","dot","(","D",",","C",")",")","=","colspan","(","dot","(","D",",","dot","(","pinv","(","D",")",",","T",")",")",")","where","pinv","(","D",")","is","the","generalized","inverse","of","D.","Further",",","the","matrix","Tnew","=","dot","(","C",",","D",")","is","full","rank",".","The","rank","attribute","is","the","rank","of","dot","(","D",",","dot","(","pinv","(","D",")",",","T",")",")","In","a","regression","model",",","the","contrast","tests","that","E","(","dot","(","Tnew",",","Y",")",")","=","0","for","each","column","of","Tnew",".","Parameters","--","--","--","--","--","term",":","array_like","design",":","array_like","Attributes","--","--","--","--","--","contrast_matrix","Examples","--","--","--","--",">",">",">","import","statsmodels.api","as","sm",">",">",">","from","statsmodels.stats.contrast","import","Contrast",">",">",">","import","numpy","as","np",">",">",">","np.random.seed","(","54321",")",">",">",">","X","=","np.random.standard_normal","(","(","40,10",")",")","#","Get","a","contrast",">",">",">","new_term","=","np.column_stack","(","(","X","[",":",",0","]",",","X","[",":",",2","]",")",")",">",">",">","c","=","Contrast","(","new_term",",","X",")",">",">",">","test","=","[","[","1","]","+","[","0","]","*","9",",","[","0","]","*","2","+","[","1","]","+","[","0","]","*","7","]",">",">",">","np.allclose","(","c.contrast_matrix",",","test",")","True","Get","another","contrast",">",">",">","P","=","np.dot","(","X",",","np.linalg.pinv","(","X",")",")",">",">",">","resid","=","np.identity","(","40",")","-","P",">",">",">","noise","=","np.dot","(","resid",",","np.random.standard_normal","(","(","40,5",")",")",")",">",">",">","new_term2","=","np.column_stack","(","(","noise",",","X","[",":",",2","]",")",")",">",">",">","c2","=","Contrast","(","new_term2",",","X",")",">",">",">","print","(","c2.contrast_matrix",")","[","-1.26424750e-16","8.59467391e-17","1.56384718e-01","-2.60875560e-17","-7.77260726e-17","-8.41929574e-18","-7.36359622e-17","-1.39760860e-16","1.82976904e-16","-3.75277947e-18","]","Get","another","contrast",">",">",">","zero","=","np.zeros","(","(","40",",",")",")",">",">",">","new_term3","=","np.column_stack","(","(","zero",",","X","[",":",",2","]",")",")",">",">",">","c3","=","Contrast","(","new_term3",",","X",")",">",">",">","test2","=","[","0","]","*","2","+","[","1","]","+","[","0","]","*","7",">",">",">","np.allclose","(","c3.contrast_matrix",",","test2",")","True"]
code: def __init__(self, term, design):
      self.term = np.asarray(term)
      self.design = np.asarray(design)
  
imports: import numpy
  from scipy.stats import f
  from scipy.stats import t
  from scipy import stats
  from statsmodels.tools.tools import clean0, fullrank
  from statsmodels.stats.multitest import multipletests
label_desc: Use image node_id 2 to create a new Contrast object  with example: obj = Contrast(term, design)