class_docstr: Nested Multinomial Logit with Random Utility 2 parameterization
  
  
  Parameters
  ----------
  endog : ndarray
      not used in this part
  exog : dict_like
      dictionary access to data where keys correspond to branch and leaf
      names. The values are the data arrays for the exog in that node.
  tree : nested tuples and lists
      each branch, tree or subtree, is defined by a tuple
      (branch_name, [subtree1, subtree2, ..., subtreek])
      Bottom branches have as subtrees the list of leaf names.
  paramsind : dictionary
      dictionary that maps branch and leaf names to the names of parameters,
      the coefficients for exogs)
  
  Methods
  -------
  get_probs
  
  Attributes
  ----------
  branches
  leaves
  paramsnames
  parinddict
  
  Notes
  -----
  endog needs to be encoded so it is consistent with self.leaves, which
  defines the columns for the probability array. The ordering in leaves is
  determined by the ordering of the tree.
  In the dummy encoding of endog, the columns of endog need to have the
  same order as self.leaves. In the integer encoding, the integer for a
  choice has to correspond to the index in self.leaves.
  (This could be made more robust, by handling the endog encoding internally
  by leaf names, if endog is defined as categorical variable with
  associated category level names.)
code: def __init__(self, endog, exog, tree, paramsind):
      self.endog = endog
      self.datadict = exog
      self.tree = tree
      self.paramsind = paramsind
  
      self.branchsum = ""
      self.probs = {}
      self.probstxt = {}
      self.branchleaves = {}
      self.branchvalues = (
          {}
      )  # just to keep track of returns by branches
      self.branchsums = {}
      self.bprobs = {}
      self.branches, self.leaves, self.branches_degenerate = getnodes(
          tree
      )
      self.nbranches = len(self.branches)
  
      # copied over but not quite sure yet
      # unique, parameter array names,
      # sorted alphabetically, order is/should be only internal
  
      self.paramsnames = sorted(
          {i for j in paramsind.values() for i in j}
      ) + ["tau_%s" % bname for bname in self.branches]
  
      self.nparams = len(self.paramsnames)
  
      # mapping coefficient names to indices to unique/parameter array
      self.paramsidx = {
          name: idx for (idx, name) in enumerate(self.paramsnames)
      }
  
      # mapping branch and leaf names to index in parameter array
      self.parinddict = {
          k: [self.paramsidx[j] for j in v]
          for k, v in self.paramsind.items()
      }
  
      self.recursionparams = 1.0 + np.arange(len(self.paramsnames))
      # for testing that individual parameters are used in the right place
      self.recursionparams = np.zeros(len(self.paramsnames))
      # self.recursionparams[2] = 1
      self.recursionparams[-self.nbranches :] = 1
  
file_path: statsmodels/statsmodels/sandbox/regression/treewalkerclass.py
imports: from statsmodels.compat.python import lrange
  from pprint import pprint
  import numpy
label_desc: Use image node_id 1 to create a new RU2NMNL object  with example: obj = RU2NMNL(endog, exog, tree, paramsind)