code: def fdrcorrection(pvals, alpha=0.05, method="indep", is_sorted=False):
      """
      pvalue correction for false discovery rate.
  
      This covers Benjamini/Hochberg for independent or positively correlated and
      Benjamini/Yekutieli for general or negatively correlated tests.
  
      Parameters
      ----------
      pvals : array_like, 1d
          Set of p-values of the individual tests.
      alpha : float, optional
          Family-wise error rate. Defaults to ``0.05``.
      method : {'i', 'indep', 'p', 'poscorr', 'n', 'negcorr'}, optional
          Which method to use for FDR correction.
          ``{'i', 'indep', 'p', 'poscorr'}`` all refer to ``fdr_bh``
          (Benjamini/Hochberg for independent or positively
          correlated tests). ``{'n', 'negcorr'}`` both refer to ``fdr_by``
          (Benjamini/Yekutieli for general or negatively correlated tests).
          Defaults to ``'indep'``.
      is_sorted : bool, optional
          If False (default), the p_values will be sorted, but the corrected
          pvalues are in the original order. If True, then it assumed that the
          pvalues are already sorted in ascending order.
  
      Returns
      -------
      rejected : ndarray, bool
          True if a hypothesis is rejected, False if not
      pvalue-corrected : ndarray
          pvalues adjusted for multiple hypothesis testing to limit FDR
  
      Notes
      -----
      If there is prior information on the fraction of true hypothesis, then alpha
      should be set to ``alpha * m/m_0`` where m is the number of tests,
      given by the p-values, and m_0 is an estimate of the true hypothesis.
      (see Benjamini, Krieger and Yekuteli)
  
      The two-step method of Benjamini, Krieger and Yekutiel that estimates the number
      of false hypotheses will be available (soon).
  
      Both methods exposed via this function (Benjamini/Hochberg, Benjamini/Yekutieli)
      are also available in the function ``multipletests``, as ``method="fdr_bh"`` and
      ``method="fdr_by"``, respectively.
  
      See also
      --------
      multipletests
  
      """
      pvals = np.asarray(pvals)
      assert (
          pvals.ndim == 1
      ), "pvals must be 1-dimensional, that is of shape (n,)"
  
      if not is_sorted:
          pvals_sortind = np.argsort(pvals)
          pvals_sorted = np.take(pvals, pvals_sortind)
      else:
          pvals_sorted = pvals  # alias
  
      if method in ["i", "indep", "p", "poscorr"]:
          ecdffactor = _ecdf(pvals_sorted)
      elif method in ["n", "negcorr"]:
          cm = np.sum(
              1.0 / np.arange(1, len(pvals_sorted) + 1)
          )  # corrected this
          ecdffactor = _ecdf(pvals_sorted) / cm
      ##    elif method in ['n', 'negcorr']:
      ##        cm = np.sum(np.arange(len(pvals)))
      ##        ecdffactor = ecdf(pvals_sorted)/cm
      else:
          raise ValueError("only indep and negcorr implemented")
      reject = pvals_sorted <= ecdffactor * alpha
      if reject.any():
          rejectmax = max(np.nonzero(reject)[0])
          reject[:rejectmax] = True
  
      pvals_corrected_raw = pvals_sorted / ecdffactor
      pvals_corrected = np.minimum.accumulate(
          pvals_corrected_raw[::-1]
      )[::-1]
      del pvals_corrected_raw
      pvals_corrected[pvals_corrected > 1] = 1
      if not is_sorted:
          pvals_corrected_ = np.empty_like(pvals_corrected)
          pvals_corrected_[pvals_sortind] = pvals_corrected
          del pvals_corrected
          reject_ = np.empty_like(reject)
          reject_[pvals_sortind] = reject
          return reject_, pvals_corrected_
      else:
          return reject, pvals_corrected
  
file_path: statsmodels/statsmodels/stats/multitest.py
imports: import numpy
  from statsmodels.stats._knockoff import RegressionFDR
label_desc: Use image node_id 3 for calling a global function with example usage: fdrcorrection(pvals, alpha, method, is_sorted) and returns: reject_,  pvals_corrected_, reject,  pvals_corrected