class_docstr: A regression model with diagonal but non-identity covariance structure.
  
  The weights are presumed to be (proportional to the) inverse
  of the variance of the observations.
  
  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 = WLSModel(dmtx, weights=range(1,8))
  >>> results = model.fit(data['Y'])
  >>> results.theta
  array([ 0.0952381 ,  2.91666667])
  >>> results.t()
  array([ 0.35684428,  2.0652652 ])
  >>> print(results.Tcontrast([0,1]))  #doctest: +FLOAT_CMP
  <T contrast: effect=2.91666666667, sd=1.41224801095, t=2.06526519708,
  df_den=5>
  >>> print(results.Fcontrast(np.identity(2)))  #doctest: +FLOAT_CMP
  <F contrast: F=26.9986072423, df_den=5, df_num=2>
class_docstr_tok: ["A","regression","model","with","diagonal","but","non-identity","covariance","structure",".","The","weights","are","presumed","to","be","(","proportional","to","the",")","inverse","of","the","variance","of","the","observations",".","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","=","WLSModel","(","dmtx",",","weights=range","(","1,8",")",")",">",">",">","results","=","model.fit","(","data","[","'","Y","'","]",")",">",">",">","results.theta","array","(","[","0.0952381",",","2.91666667","]",")",">",">",">","results.t","(",")","array","(","[","0.35684428",",","2.0652652","]",")",">",">",">","print","(","results.Tcontrast","(","[","0,1","]",")",")","#","doctest",":","+FLOAT_CMP","<","T","contrast",":","effect=2.91666666667",",","sd=1.41224801095",",","t=2.06526519708",",","df_den=5",">",">",">",">","print","(","results.Fcontrast","(","np.identity","(","2",")",")",")","#","doctest",":","+FLOAT_CMP","<","F","contrast",":","F=26.9986072423",",","df_den=5",",","df_num=2",">"]
code: def __init__(self, design, weights=1):
      weights = np.array(weights)
      if weights.shape == ():  # scalar
          self.weights = weights
      else:
          design_rows = design.shape[0]
          if not (
              weights.shape[0] == design_rows
              and weights.size == design_rows
          ):
              raise ValueError(
                  "Weights must be scalar or same length as design"
              )
          self.weights = weights.reshape(design_rows)
      super().__init__(design)
  
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 1 to create a new WLSModel object from inherited base classes: OLSModel with example: obj = WLSModel(design, weights)