class_docstr: Autoregressive working covariance for QIF regression.
code: def mat(self, dim, term):
      if dim < 3:
          msg = (
              "Groups must have size at least 3 for "
              + "autoregressive covariance."
          )
          raise ValueError(msg)
  
      if term == 0:
          return np.eye(dim)
      elif term == 1:
          mat = np.zeros((dim, dim))
          mat.flat[1 :: (dim + 1)] = 1
          mat += mat.T
          return mat
      elif term == 2:
          mat = np.zeros((dim, dim))
          mat[0, 0] = 1
          mat[dim - 1, dim - 1] = 1
          return mat
      else:
          return None
  
imports: import numpy
  from collections import defaultdict
  import statsmodels.base.model
  from statsmodels.genmod import families
  from statsmodels.genmod.generalized_linear_model import GLM
  from statsmodels.genmod.families import links
  from statsmodels.genmod.families import varfuncs
  import statsmodels.regression.linear_model
  import statsmodels.base.wrapper
  from statsmodels.tools.decorators import cache_readonly
label_desc: Use image node_id 2 for calling the QIFAutoregressive obj's underlying member method code with example usage: obj.mat(dim, term) and returns: np, mat, mat, None