code: def get_thsd(mci):
      var_ = np.var(
          mci.groupstats.groupdemean(), ddof=len(mci.groupsunique)
      )
      means = mci.groupstats.groupmean
      nobs = mci.groupstats.groupnobs
      resi = tukeyhsd(
          means,
          nobs,
          var_,
          df=None,
          alpha=0.05,
          q_crit=qsturng(0.95, len(means), (nobs - 1).sum()),
      )
      print(resi[4])
      var2 = (mci.groupstats.groupvarwithin() * (nobs - 1)).sum() / (
          nobs - 1
      ).sum()
      assert_almost_equal(var_, var2, decimal=14)
      return resi
  
file_path: statsmodels/statsmodels/examples/try_tukey_hsd.py
imports: from io import StringIO
  import numpy
  from numpy.testing import assert_almost_equal, assert_equal
  from scipy import stats
  from statsmodels.stats.libqsturng import qsturng
  from statsmodels.stats.multicomp import tukeyhsd
  import statsmodels.stats.multicomp
label_desc: Use image node_id 1 for calling a global function with example usage: get_thsd(mci) and returns: resi