% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hnp_package.r
\name{hnp_boxplot}
\alias{hnp_boxplot}
\title{HNP Under-classification Error Box Plot}
\usage{
hnp_boxplot(
  conf_1,
  conf_2 = NULL,
  levels = NULL,
  tolerances = NULL,
  name_1 = "Classical",
  name_2 = "H-NP"
)
}
\arguments{
\item{conf_1}{A list of \verb{T x T} confusion matrices (one per run) for the
first method.}

\item{conf_2}{Optional list of \verb{T x T} confusion matrices (one per run) for
the second method, with the same number of runs as \code{conf_1}. If \code{NULL},
only \code{conf_1} is plotted (single mode).}

\item{levels}{Optional numeric vector of length \code{T - 1}. Control levels
(alpha) per class; drawn as dashed reference lines. Each must lie in (0, 1).}

\item{tolerances}{Optional numeric vector of length \code{T - 1}. Tolerances
(delta) per class; used to mark the \code{(1 - delta)} quantile as red points.
Each must lie in (0, 1).}

\item{name_1}{Character. Legend label for the first method.}

\item{name_2}{Character. Legend label for the second method (used only when
\code{conf_2} is provided).}
}
\value{
Invisibly draws the boxplot and returns a list with two components:
\code{classwise} (a data.frame of per-class control level, tolerance,
under-classification error mean/sd, and violation rate) and \code{overall}
(a data.frame of the overall misclassification error mean and sd).
}
\description{
Summarize and visualize the under-classification errors and the
overall misclassification error across repeated runs for a \code{T}-class
problem. Given a list of confusion matrices (one per run), it draws grouped
boxplots of the class-wise under-classification errors and the overall
error. When a second list of confusion matrices is supplied, the two
methods (e.g. a classical classifier vs. H-NP) are compared side by side.
Optional control levels and tolerances add reference lines and
\code{(1 - delta)} quantile markers.
}
\examples{
set.seed(123)
make_cm <- function() {
  m <- matrix(sample(5:20, 9, replace = TRUE), 3, 3)
  dimnames(m) <- list(c("1", "2", "3"), c("1", "2", "3"))
  m
}
conf_classical <- replicate(20, make_cm(), simplify = FALSE)
conf_hnp <- replicate(20, make_cm(), simplify = FALSE)
tab <- hnp_boxplot(
  conf_1 = conf_classical,
  conf_2 = conf_hnp,
  levels = c(0.1, 0.1),
  tolerances = c(0.1, 0.1)
)
}
\references{
Lijia Wang, Y. X. Rachel Wang, Jingyi Jessica Li, and Xin Tong (2024).
"Hierarchical Neyman-Pearson Classification for Prioritizing Severe Disease
Categories in COVID-19 Patient Data."
\emph{Journal of the American Statistical Association}, 119(545), 39-51.
\doi{10.1080/01621459.2023.2270657}
}
