class_docstr: Tests for multiple comparisons
  
  Parameters
  ----------
  data : ndarray
      independent data samples
  groups : ndarray
      group labels corresponding to each data point
  group_order : list[str], optional
      the desired order for the group mean results to be reported in. If
      not specified, results are reported in increasing order.
      If group_order does not contain all labels that are in groups, then
      only those observations are kept that have a label in group_order.
class_docstr_tok: ["Tests","for","multiple","comparisons","Parameters","--","--","--","--","--","data",":","ndarray","independent","data","samples","groups",":","ndarray","group","labels","corresponding","to","each","data","point","group_order",":","list","[","str","]",",","optional","the","desired","order","for","the","group","mean","results","to","be","reported","in",".","If","not","specified",",","results","are","reported","in","increasing","order",".","If","group_order","does","not","contain","all","labels","that","are","in","groups",",","then","only","those","observations","are","kept","that","have","a","label","in","group_order","."]
docstr: Tukey's range test to compare means of all pairs of groups
  
  Parameters
  ----------
  alpha : float, optional
      Value of FWER at which to calculate HSD.
  
  Returns
  -------
  results : TukeyHSDResults instance
      A results class containing relevant data and some post-hoc
      calculations
docstr_tok: ["Tukey","'s","range","test","to","compare","means","of","all","pairs","of","groups","Parameters","--","--","--","--","--","alpha",":","float",",","optional","Value","of","FWER","at","which","to","calculate","HSD",".","Returns","--","--","--","-","results",":","TukeyHSDResults","instance","A","results","class","containing","relevant","data","and","some","post-hoc","calculations"]
code: def tukeyhsd(self, alpha=0.05):
      """
      Tukey's range test to compare means of all pairs of groups
  
      Parameters
      ----------
      alpha : float, optional
          Value of FWER at which to calculate HSD.
  
      Returns
      -------
      results : TukeyHSDResults instance
          A results class containing relevant data and some post-hoc
          calculations
      """
      self.groupstats = GroupsStats(
          np.column_stack([self.data, self.groupintlab]), useranks=False
      )
  
      gmeans = self.groupstats.groupmean
      gnobs = self.groupstats.groupnobs
      # var_ = self.groupstats.groupvarwithin()
      # #possibly an error in varcorrection in this case
      var_ = np.var(self.groupstats.groupdemean(), ddof=len(gmeans))
      # res contains: 0:(idx1, idx2), 1:reject, 2:meandiffs, 3: std_pairs,
      # 4:confint, 5:q_crit, 6:df_total, 7:reject2, 8: pvals
      res = tukeyhsd(
          gmeans, gnobs, var_, df=None, alpha=alpha, q_crit=None
      )
  
      resarr = np.array(
          lzip(
              self.groupsunique[res[0][0]],
              self.groupsunique[res[0][1]],
              np.round(res[2], 4),
              np.round(res[8], 4),
              np.round(res[4][:, 0], 4),
              np.round(res[4][:, 1], 4),
              res[1],
          ),
          dtype=[
              ("group1", object),
              ("group2", object),
              ("meandiff", float),
              ("p-adj", float),
              ("lower", float),
              ("upper", float),
              ("reject", np.bool_),
          ],
      )
      results_table = SimpleTable(resarr, headers=resarr.dtype.names)
      results_table.title = (
          "Multiple Comparison of Means - Tukey HSD, "
          + "FWER=%4.2f" % alpha
      )
  
      return TukeyHSDResults(
          self,
          results_table,
          res[5],
          res[1],
          res[2],
          res[3],
          res[4],
          res[6],
          res[7],
          var_,
          res[8],
      )
  
imports: from collections import namedtuple
  from statsmodels.compat.python import lzip, lrange
  import copy
  import math
  import numpy
  from numpy.testing import assert_almost_equal, assert_equal
  from scipy import stats, interpolate
  from statsmodels.iolib.table import SimpleTable
  from statsmodels.stats.multitest import multipletests, _ecdf, fdrcorrection, fdrcorrection_twostage
  from statsmodels.graphics import utils
  from statsmodels.tools.sm_exceptions import ValueWarning
label_desc: Use image node_id 5 for calling the MultiComparison obj's underlying member method code with example usage: obj.tukeyhsd(alpha) and returns: TukeyHSDResults