code: def _test_group(pvalues, group_name, group, exact=True):
      """test if the objects in the group are different from the general set.
  
      The test is performed on the pvalues set (ad a pandas series) over
      the group specified via a fisher exact test.
      """
      from scipy.stats import fisher_exact, chi2_contingency
  
      totals = 1.0 * len(pvalues)
      total_significant = 1.0 * np.sum(pvalues)
      cross_index = [c for c in group if c in pvalues.index]
      missing = [c for c in group if c not in pvalues.index]
      if missing:
          s = (
              "the test is not well defined if the group "
              "has elements not presents in the significativity "
              "array. group name: {}, missing elements: {}"
          )
          logging.warning(s.format(group_name, missing))
      # how many are significant and not in the group
      group_total = 1.0 * len(cross_index)
      group_sign = 1.0 * len([c for c in cross_index if pvalues[c]])
      group_nonsign = 1.0 * (group_total - group_sign)
      # how many are significant and not outside the group
      extern_sign = 1.0 * (total_significant - group_sign)
      extern_nonsign = 1.0 * (
          totals - total_significant - group_nonsign
      )
      # make the fisher test or the chi squared
      test = fisher_exact if exact else chi2_contingency
      table = [
          [extern_nonsign, extern_sign],
          [group_nonsign, group_sign],
      ]
      pvalue = test(np.array(table))[1]
      # is the group more represented or less?
      part = group_sign, group_nonsign, extern_sign, extern_nonsign
      # increase = (group_sign / group_total) > (total_significant / totals)
      increase = np.log(
          (totals * group_sign) / (total_significant * group_total)
      )
      return pvalue, increase, part
  
file_path: statsmodels/statsmodels/sandbox/multilinear.py
imports: from patsy import dmatrix
  import pandas
  from statsmodels.api import OLS
  from statsmodels.api import stats
  import numpy
  import logging
label_desc: Use image node_id 3 for calling a global function with example usage: _test_group(pvalues, group_name, group, exact) and returns: pvalue,  increase,  part