% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/BH_diagnostics.R
\name{dfdr_bh_diagnostics}
\alias{dfdr_bh_diagnostics}
\title{BH diagnostics at a headline alpha (threshold, discoveries, boundary support)}
\usage{
dfdr_bh_diagnostics(
  x,
  alpha = 0.01,
  boundary = c("mult", "add"),
  win = 0.2,
  delta = NULL
)
}
\arguments{
\item{x}{A \code{dfdr_tbl} (or data frame) containing columns \code{id} and
\code{p}.}

\item{alpha}{Numeric BH FDR level in \eqn{(0,1)}.}

\item{boundary}{Character. One of \code{"mult"} (multiplicative window) or
\code{"add"} (additive window).}

\item{win}{Numeric. Relative width for the multiplicative boundary window
(default 0.2). Used when \code{boundary = "mult"}, defining the interval
\eqn{(t_\alpha, (1+\mathrm{win})t_\alpha]}.}

\item{delta}{Numeric. Additive width for the additive boundary window. Required
when \code{boundary = "add"}, defining the interval \eqn{(t_\alpha, t_\alpha+\delta]}.}
}
\value{
A list with two elements:
\describe{
\item{headline}{A one-row \link[tibble:tibble]{tibble} containing BH summary
diagnostics, including \code{t_alpha} (the BH threshold), \code{R_alpha} (the
number of rejected hypotheses / discoveries), and \code{N_boundary} (the
number of p-values in a right-neighborhood above the cutoff as determined by
\code{boundary}, \code{win}, and \code{delta}).}
\item{accepted}{A character vector of \code{id} values corresponding to
discoveries (rows with \code{p <= t_alpha}). If no finite BH threshold exists,
this is \code{character(0)}.}
}
}
\description{
Computes the Benjamini--Hochberg (BH) rejection threshold \eqn{t_\alpha}, the
number of discoveries \eqn{R_\alpha}, and a simple "boundary support" measure:
the number of p-values just above \eqn{t_\alpha}. Boundary support is intended
to indicate how sensitive the discovery set may be to small perturbations of
p-values near the cutoff.
}
\examples{
library(tibble)

set.seed(1)
n <- 5000
x <- tibble(
  id = as.character(seq_len(n)),
  p = c(stats::runif(4500), stats::rbeta(500, 0.3, 1))
)

out <- dfdr_bh_diagnostics(x, alpha = 0.01, boundary = "mult", win = 0.2)
out$headline
length(out$accepted)

}
