\subsection{Simulation setting}
Datasets are simulated from a mixture of 3 bidimensional Gaussian distributions whose mean vectors are $(-1,0)$, $(0,D)$ and $(1,0)$, respectively. Here $D$ is a parameter that tunes the distance between populations 1 and 3 and population 2. When $D=0$ the three populations are highly overlapping, whereas a high value of $D$ makes the populations more distinct. In each class the covariance matrix is diagonal, with an identical variance $\sigma^2$. Weights $\pi_1,\pi_2,\pi_3$ are all fixed at 1/3. For each dataset, 200 observations per population are simulated. In this context the easiness of the classification task is ruled by parameters $D$ and $\sigma^2$: the higher $D$ (respectively the lower $\sigma^2$), the easier the classification. Several values are considered for $D$ (0, 1, 2, 3) and $\sigma^2$ (0.5, 1, 2). An illustration of different configurations ranging from an ``easy'' classification case ($D=3$, $\sigma^2=0.5$) to a ``hard'' one ($D=0$, $\sigma^2=2$) can be found in Appendix C. Finally, 100 datasets are generated for each configuration.

\blue{In a supplementary simulation study, datasets were generated from a mixture of three bivariate Student distributions; details can be found in Appendix F.}





\subsection{\blue{Case 1: posterior probabilities are known}}

In what follows the objective is to perform classification with a MFDR controlled at a nominal threshold fixed at $\alpha=0.05$.

In Section 2.2, a straightforward calculation has shown that
the thresholded classification rule $\psi_\alpha$ with a threshold fixed at $1-\alpha$ guarantees
a MFDR control at a level $\alpha$. However the results of Section 3.3 suggest that fixing the threshold at $1-\alpha$ may result in a high MFNR. The alternative procedure for the optimal rule described in Section \ref{Subsect: EstimationOfLambda} should yield better performance thanks to a less conservative choice for the threshold. The potential gain (in terms of MFNR) of the optimal rule compared to the $1-\alpha$ thresholded rule is investigated in this section.

The analysis is performed as follows: for each dataset the posterior probabilities are computed for each observation
\blue{using the true parameters of the model}. The procedure \eqref{Equ : OptimalRule-FDR-KinfP} is then applied to estimate the threshold $\lambda$ in order to control the MFDR at nominal level $\alpha=0.05$. Observations are classified using either the MAP rule, the thresholded rule (with $\alpha=0.05$) or the estimated optimal rule (i.e. the optimal rule applied with estimated threshold $\widehat{\lambda}$). For all rules the actual $MFDR$ and $MFNR$ are evaluated by comparing the predicted and true labels of the classified observations. Results are displayed in Figure \ref{Fig:simulations_known} for the case where all classes are of interest. The case where only classes 1 and 3 are of interest is provided in Appendix D.


\begin{figure}
  \centering
\includegraphics[scale=0.7]{AnalyseSimulation3Pops2019_known_all.pdf}  
\caption{ Performances of the MAP, optimal and $1-\alpha$ thresholded classification rules in terms of realized MFDR and MFNR. Columns correspond to different values of the variance $\sigma^2$. The black line on the top graphs corresponds to the nominal level of 5\%. This figure appears in color in the electronic version of this article, and color refers to that version.\label{Fig:simulations_known}}
\end{figure}

In the case where $\sigma^2=0.5$ one can observe that all classification rules achieve a low MFDR - that may still be much higher than 0.05 in the case of the MAP rule. Both the thresholded and the optimal rule efficiently achieve control of the MFDR at the nominal level, but with significant differences in terms of MFNR. As illustrated in Figure \ref{Fig: Lambdas}, the estimated threshold for the optimal rule may be much lower (below 0.5 in some configurations) than the $1-\alpha = 0.95$ value used in the thresholded rule. As a consequence, the MFNR is twice higher for the thresholded rule than for the optimal rule, illustrating how conservative the thresholded rule can be.

\begin{figure}
  \centering
\includegraphics[scale=0.5]{AnalyseSimulation3Pops2019_known_all_Lambdas.pdf}
 \bigskip
 \bigskip
 \caption{Boxplots of the estimated threshold for the optimal rule. Colors correspond to levels of the variance $\sigma^2$. The horizontal line indicates the threshold 0.95 used in the thresholded rule. This figure appears in color in the electronic version of this article.\label{Fig: Lambdas}}
\end{figure}

In the case where $\sigma^2=2$ the classification task becomes quite difficult, and the MAP rule yields MFDR that are higher than 50\%. In such configurations both the thresholded and the optimal rules do not classify any observation in most cases, since the highest posterior probability observed (in a class of interest) is lower than 0.95.

In conclusion, whatever the configuration, the optimal rule $\psi_{\widehat{R}^*}$ with estimated threshold $\widehat{\lambda}$ controls the misclassification rate as requested, whereas the thresholded classification rule is more conservative. When the classification task is easy or intermediate the MFNR of the optimal rule can be much smaller than the MFNR of the thresholded classification rule. Results are unchanged if the prior proportions of the mixture vary (not shown), and/or if only a subset of the three classes are of interest (see Appendix D).

\subsection{\blue{Case 2: posterior probabilities are inferred}}

So far we assumed that the true parameters of the mixture are known, but in practice these parameters are usually estimated from the data at hand.
To evaluate the impact of parameter estimation on misclassification rate, we performed the same analysis as in the previous section, except that parameters are now supposed to be unknown and are estimated using the \blue{\texttt{mclust} R package \citep{Scrucca16}}, fixing the number of classes to its true value (i.e. 3). Results are displayed in Figure \ref{Fig:simulations_est}.

\begin{figure}
\includegraphics[scale=0.7]{./AnalyseSimulation3Pops2019_est_all.pdf}
\bigskip
\bigskip
\caption{Same figure as Figure \ref{Fig:simulations_known}, except that posterior probabilities are now estimated. This figure appears in color in the electronic version of this article. \label{Fig:simulations_est}}
\end{figure}

When the classification problem is tractable (low or moderate values of $\sigma^2$ and/or high values of $D$) both the thresholded and the optimal rules efficiently control the MFDR. As in the previous scenario, a significant gain in terms of MFDR is observed when using the optimal rule rather the thresholded rule.
When the classification problem becomes too difficult (i.e. classes strongly overlap) the estimated posterior probabilities get inaccurate, and any classification rule based on these quantities becomes irrelevant. Although neither the thresholded nor the optimal rule control the MFDR at the nominal level, it is still worth to use one of these classification rules rather than the MAP rule. Considering the case where only a subset of classes is of interest leads to similar conclusions (see Figure \ref{Fig:simulations_est_ClInt} in Appendix D).

\blue{The performance of the optimal rule depends on the accuracy of the posterior probability estimates. In order to explore the robustness of our method under model misspecification that could possibly lead to biased posterior probabilities estimates, we generated datasets according to a mixture of three Student bidimensional distributions with the same centers and covariance matrices as in the main Gaussian simulation scheme of ``intermediate'' difficulty ($\sigma=1$). We then estimated the posterior probabilities using the EM algorithm for Gaussian mixtures implemented in \texttt{mclust}. Results are shown in Appendix F. As expected, for higher degrees of freedom, the error rates closely match the ones in the central column ($\sigma=1$) of Figure \ref{Fig:simulations_est}. For lower degrees of freedom, performance breaks down in the ``difficult'' configurations given by low values of $D$. For more tractable configurations, MFDR control is generally achieved and we do not observe notably differences in terms of MFNR with respect to the Gaussian simulations.}



\subsection{Application to transcriptomic data}

We consider the unsupervised classification problem described in \cite{Berard2011}. A methylation experiment was performed to compare the methylation profiles of two organs (leaf and seed) of Arabidopsis thaliana. The methylation profiles were measured on a same plant using a tiling array technology. The genomic sequence of Arabidopsis thaliana is represented on the array by approximately $5\times10^5$ probes, covering both genic and intergenic regions. For each probe, the methylation signal is measured in the two organs. From a statistical point of view the sampled population is the population of probes, each of them being described by a bivariate signal (hybridization in leaf and seed), and the goal of the analysis is to identify differentially methylated probes, i.e. probes whose methylation signals in leaf and seed differ. In the following only probes corresponding to chromosome 4 (107,199 probes) are considered. A more thorough description of the data can be found in \cite{Berard2011}.

In \cite{Berard2011} a constrained Gaussian bivariate mixture model was fitted to the data. \blue{Comparing two samples requires distinguishing four different classes of probes that can be biologically interpreted as follows : a class of probes with low methylation signals (1), a class of probes exhibiting a similar intensity level in both organs (2), a class of probes with lower methylation intensities in leaf compared to seed (3), and a symmetric class of probes with higher intensities in leaf compared to seed (4)} (see Appendix E for a graphical representation of the model, and the original article for technical details). \blue{Note that in the initial article the number of classes of the mixture was directly deduced from the biological comparison to be performed}.  Based on this four component mixture model, posterior probabilities to belong to each class were computed for each probe. In the original article the MAP rule was applied to infer class memberships, and probes classified into one of the two classes of interest (under and over-methylated classes) were identified and further investigated. Starting from the same posterior probabilities as in the original publication, we performed probe classification into the classes of interest using the optimal classification rule defined in section \ref{Sect : Shape}. Here $P=4$ and $K=2$, and the MFDR is controlled at nominal level $\alpha=0.1$. Among the 15,801 probes initially classified as under or over-methylated, 13,065 are classified by the resulting MFDR classification rule, yielding an MFNR estimated at 0.0624.

The different classification rules are illustrated in Figure \ref{Fig: ClassifiedMethylationData}. The left panel represents the MAP rule used in the initial analysis (black = non-methylated, red = identically methylated, blue = under-methylated in leaf, green = over-methylated in leaf). The center panel corresponds to the optimal rule. Here the same colouring of the points is applied, with grey points corresponding to probes unclassified by the optimal rule and purple points corresponding to probes initially classified as over or under-methylated by the MAP rule but unclassified by the optimal rule.

As expected, all purple points are positioned on the boundaries between the two classes of interest and the two other classes. Although the posterior probability to be either over-methylated or under-methylated is higher than any other one for these probes, the actual value of the maximal posterior probability may be quite low, ranging between 0.25 and 0.6 (see Figure \ref{Fig: ClassifiedMethylationData}, right). In contrast, all probes classified by the optimal rule have posterior probabilities higher than 0.57. One can also notice that the optimal classification rule discards some obvious spurious classifications, such as the ones observed for very low values of the methylation signal, that were probably due to the constrained shapes of the covariance matrices of the adjusted model. Such points are discarded due to their low posterior probabilities.

\begin{figure}
\begin{center}
\begin{tabular}{cc}
\includegraphics[width=5cm]{./ClassificationMAP.png} &
\includegraphics[width=5cm]{./ClassificationMFDR_34.png}
\includegraphics[width=5cm]{./HistPostProbForUnclassified34.png}
\end{tabular}
\end{center}
\bigskip
\bigskip
\caption{\textbf{Left:} Probes of chromosome 4 coloured according to the MAP classification rule. \textbf{Center:} Probes of chromosome 4 coloured according to the optimal classification rule. \textbf{Right:} Histogram of the maximum posterior probabilities for purple probes classified by the MAP rule but not by the optimal rule. This figure appears in color in the electronic version of this article.\label{Fig: ClassifiedMethylationData}}
\end{figure}


In order to gain some additional insight regarding the boundary probes, we investigated to which extent the classification of a given probe is consistent with the ones of the adjacent (left and right) probes\footnote{Although not accounted for in the initial publication, the information about the genomic position of the probes is available.}. For a given probe, the classification consistency score counts the number of adjacent probes sharing the same classification status. This score takes value 0, 1 or 2, with 2 indicating a high classification consistency between the probe and its two neighbours.

Table \ref{Tab: ClassifVsConsistency} displays the distribution of probes in terms of class assignment and classification consistency, for the MAP rule (left) and the optimal rule (right). Focusing on class ``over-methylated'' one notices that the proportion of probes with score 1 or 2 is higher when using the optimal classification rule rather than the MAP classification rule. This illustrates the fact that most of the probes discarded by the optimal rule (corresponding to the purple points of Figure \ref{Fig: ClassifiedMethylationData}, center) are isolated probes exhibiting weak evidence for methylation. One can conclude that applying the optimal rule yields a more robust set of candidate probes by shaving inconsistent candidates.

\begin{table}
  \begin{small}
    \centerline{
\begin{tabular}{c}
\input{SummaryLagMAP_Consistency} \\
(a) \\
\input{SummaryLagMFDR_Consistency} \\
 (b)
\end{tabular}\\}
\end{small}
\caption{\textbf{(a)} Distribution of the probe counts in terms of MAP classification (rows) and classification consistency with neighbours (columns). The four classes correspond to ``non-methylated'' (1), ``identically methylated'' (2), ``under-methylated in leaf'' (3) and ``over-methylated in leaf'' (4). The classification consistency score counts the number of adjacent probes sharing the same classification status as the current probe. Numbers in brackets correspond to per row fractions. \textbf{(b)} Same distribution for the optimal classification. \label{Tab: ClassifVsConsistency}}
\end{table}

\subsection{Restricted classification rules}
Because the classification task may be arbitrarily difficult for some points of $\mathcal{X}$, we consider restricted rules $\psi_{R}(x)$, that classify points in a subset $R\subseteq\mathcal{X}$ only:
\begin{eqnarray*}
\psi_{R}:\mathcal{X} &\rightarrow& \{0,1,\ldots,P\},
\end{eqnarray*}
where 0 is the status ``not classified'' given to observations in $\overline{R}$, the complementary set of $R$ in $\mathcal{X}$:
$$\forall x\in \bar{R}, \ \psi_{R}(x)=0.$$
As an illustration, consider the thresholded classification rule $\psi^\alpha$ provided in equation \eqref{Def : Thresholded rule}, and define
$$\tau^*(x) = \underset{1\leq p\leq P}{\max}\ \tau_p(x),$$
which corresponds to the maximal posterior probability for point $x$. Then classification rule $\psi^\alpha$ corresponds to the restricted classification rule $\psi_{R_\alpha}$ where
$$R_\alpha=\{x |\tau^*(x)\geq1-\alpha\}.$$

In some cases, the number $K$ of classes of interest may be lower than the total number of classes $P$ in the mixture. In the following, and without loss of generality, we will assume that the classes of interest are the first $K$ classes of the mixture. In this context where $K<P$, it will be convenient to consider classification rules that are also restricted to predict labels in $1,\ldots,K$:
\begin{eqnarray*}
\psi_{K,R}:\mathcal{X} &\rightarrow& \{0,1,\ldots,K\}.
\end{eqnarray*}
In this situation, the maximal posterior probability of interest is
$$
\tau^*_K(x) = \underset{1\leq k\leq K}{\max}\ \tau_k(x).
$$
Note that in the case $K=P$ one has $\tau^*_P(x) = \tau^*(x)$. One can extend the definition of the thresholded classification rule to the case $K<P$ by defining
\begin{eqnarray}
\psi^{\alpha}_K(x) = \left\{
\begin{array}{ll}
k &  \text{ if } k =  \underset{1\leq k'\leq K}{\mbox{argmax}} \ \tau_{k'}(x) \text{ and } \tau_K^*(x)>1-\alpha,\\
0 &  \text{(not classified) otherwise},
\end{array}
\right. . \label{Def : Restricted Thresholded rule}
\end{eqnarray}

\subsection{Error rates}
A ``good'' classification rule should classify as many observations as possible while controlling the classification error rate. As in the statistical testing setting, one can introduce the type I and type II error rates associated to any given classification rule. We consider two definitions of the type I error rate and one for the type II error rate in the multiclass classification context:
\begin{definition}
Let $\{1,\ldots,K\}$ be the classes of interest (possibly with $K=P$) and $\psi_{K,R}$ be a restricted classification rule. Quantities
\begin{eqnarray*}
MNPR(\psi_{K,R}) &=& \prob{\psi_{K,R}(X)\neq Z, \  \psi_{K,R}(X)>0} = \prob{\psi_{K,R}(X)\neq Z, \  X\in R}\\
\text{and } MFDR(\psi_{K,R}) &=& 
\blue{
\begin{cases}
\prob{\psi_{K,R}(X)\neq Z | \ \psi_{K,R}(X)>0} = \prob{\psi_{K,R}(X)\neq Z | \ X\in R},\\
\qquad \text{ if } \prob{X \in R} >0\\
0, \text{ if } \prob{X \in R}=0,
\end{cases}}
\end{eqnarray*}
are called the multiclass Neyman-Pearson error rate and the multiclass false discovery rate, respectively. The quantity
\begin{eqnarray*}
MFNR(\psi_{K,R}) &=& \prob{ Z \in \{1,\ldots,K\} , \  \psi_{K,R}(X)=0} = \prob{ Z \in \{1,\ldots,K\} , \  X\in \bar{R}}
\end{eqnarray*}
is called the multiclass false negative rate.
\end{definition}
The MFNR quantifies the proportion of observations that belong to a class of interest and that were not classified by rule $\psi_{K,R}$. This quantity corresponds to the false negative proportion in the testing setting, and should be as small as possible. The MNPR and MFDR correspond to possible classification error rates one may want to control at a given level $\alpha$. \gb{Note that a criterion
equivalent to the MFDR has been considered by \citet{elyaniv2010,wiener2015,denis2020}, albeit only in the 
situation $K=P=2$}.

To exemplify the previous definitions, here again \blue{one can consider the thresholded classification rule $\psi^{\alpha}$ ($=\psi^{\alpha}_P$) defined above in the by-default context where all classes are of interest}. One can show that the MFDR of $\psi^{\alpha}$  is always lower than $\alpha$, whatever the number of classes of interest. Indeed one has
\blue{
\begin{eqnarray*}
MFDR(\psi^\alpha) &=& \prob{\psi^\alpha(X)\neq Z | \ X\in R_\alpha}\\
&=& \frac{\prob{\psi^\alpha(X)\neq Z \cap \ X\in R_\alpha}}{\prob{X\in R_\alpha}}.\\
\end{eqnarray*}
The numerator in the last expression can be reformulated as follows:
\begin{eqnarray*}
\prob{\psi^\alpha(X)\neq Z \cap \ X\in R_\alpha} &=& \int_{\mathcal{X}}\espi{Z|X=x}{\ind{\psi^\alpha(x)\neq Z}}\ind{x\in R_\alpha}f(x)dx\\
&=& \int_{\mathcal{X}}\espi{Z|X=x}{Z\neq p^*}\ind{x\in R_\alpha}f(x)dx\\
&=& \int_{\mathcal{X}}(1-\tau^*_P(x))\ind{x\in R_\alpha}f(x)dx
\end{eqnarray*}
where $p^*=\arg\underset{p}{\max}\tau_p(x)$. Plugging this expression into the previous equation leads to
\begin{eqnarray*}
MFDR(\psi^\alpha) &=& \frac{1}{\prob{X\in R_\alpha}}\int_{R_\alpha} (1-\tau^*_P(x))f(x)dx\\
&\leq& \frac{1}{\prob{X\in R_\alpha}}\int_{R_\alpha} \alpha f(x)dx\\
&\leq& \alpha.
\end{eqnarray*}
}




\subsection{Optimal classification rules}
We now introduce a formal definition for the $optimality$ of a restricted classification rule.
\begin{definition}
Given a level $\alpha$ ($0\leq \alpha \leq 1$) and a set of classes of interest  $\{1,\ldots,K\}$ (possibly with $K=P$), a classification rule $\psi_{K,R}^*$ is MNPR-optimal at level $\alpha$ if
\begin{eqnarray}
\psi_{K,R}^* = \arg\underset{\psi_{K,R}}{\min}\  MFNR(\psi_{K,R})\ \  u.c. \ \ MNPR(\psi_{K,R}) \leq \alpha . \label{Equ : NP-optimality}
\end{eqnarray}
Alternatively, $\psi_{K,R}^*$ is MFDR-optimal at level $\alpha$ if
\begin{eqnarray}
\psi_{K,R}^* = \arg\underset{\psi_{K,R}}{\min}\  MFNR(\psi_{K,R})\ \  u.c. \ \ MFDR(\psi_{K,R}) \leq \alpha . \label{Equ : FDR-optimality}
\end{eqnarray}
\end{definition}
Note that the definition implies both a region $R$ as large as possible and an optimal classification at each point $x$ in region $R$.





\subsection{Estimation of parameter $\lambda$}

\section{Introduction \label{Sect : intro}}

\input{./Introduction}

\section{Definitions \label{Sect : Definitions}}

\input{Definitions}

\section{Optimal classification rules \label{Sect : Shape}}

\input{./OptimalRegions}

\section{Applications \label{Sect : Applications}}

\input{./Applications}

\section{Discussion \label{Sect : Discussion}}

\input{./Discussion}


\section*{Acknowledgments}
G. Blanchard acknowledges support from Agence Nationale de la Recherche (ANR) via the project ANR-19-CHIA-0021-01 (BiSCottE), and
the project ANR-16-CE40-0019 (SansSouci); and
from  the Franco-German University through the binational Doktorandenkolleg CDFA 01-18.
GQE and IPS2 benefit from the support of the LabEx Saclay Plant Sciences-SPS (ANR-17-EUR-0007).

\bibliographystyle{DeGruyter}



\subsection{Optimal rule when $R$ is fixed}
Let us first define the restricted MAP classification rule $\psi^{MAP}_{K,R}$ as
\begin{eqnarray*}
\psi^{MAP}_{K,R}(x) = \left\{
\begin{array}{l}
\arg\underset{1\leq k\leq K}{\max} \tau_k(x) \text{ if } x\in R \\
0 \text{ otherwise.}
\end{array}
\right. 
\end{eqnarray*}

\blue{Let first consider a classification $\psi_{K,R}$ restricted to the region $R$. At any point $x\in R$ one has}
\begin{eqnarray*}
\prob{ \psi_{K,R}(x) \neq Z } &=& \sum_{k=1}^K (1-\tau_k(x))\ind{\psi_{K,R}(x)=k} \\
    &\geq& (1-\tau^*_K(x)) \\
    &\geq& \prob{ \psi^{MAP}_{K,R}(x) \neq Z }
\end{eqnarray*}
and therefore
\begin{eqnarray*}
MNPR(\psi_{K,R}) &\geq& MNPR(\psi^{MAP}_{K,R})\\
\text{ and } MFDR(\psi_{K,R}) &\geq& MFDR(\psi^{MAP}_{K,R}).
\end{eqnarray*}
Alternatively it is straightforward to observe that
\begin{eqnarray*}
MFNR(\psi_{K,R}) = MFNR(\psi^{MAP}_{K,R}).
\end{eqnarray*}
\blue{As a consequence, one can conclude that for a fixed region $R$ the optimal restricted classification rule is $\psi^{MAP}_{K,R}$. Therefore finding the solutions of problems \eqref{Equ : NP-optimality} and \eqref{Equ : FDR-optimality} boils down to finding the region $R^*$ to which the MAP classification rule should be applied.}

In the following the upperscript $MAP$ and the lowerscript $K$ in $\psi^{MAP}_{K,R}$ will be skipped for simplicity, and $\psi_R$ should be understood as $\psi^{MAP}_{K,R}$, with $K=P$ or $K<P$ depending on the context.




\subsection{Optimal classification region for MNPR control} \label{Subsect : MNPR control}
If all classes are of interest ($K=P$), one looks for a region $R^*$ such
that
\begin{eqnarray*}
R^* \in \underset{R}{\arg\min}\ P\gp{X\in \bar{R}} \ \text{ u.c. } \ \prob{ \psi_R(X) \neq Z , \  X\in R } \leq \alpha .
\end{eqnarray*}
If $K<P$, the region $R^*$ should satisfy
\begin{eqnarray}
\label{eq:MNPRpb}
R^* \in \underset{R}{\arg\min}\ P\gp{Z\in \{1,\ldots,K\}, \  X\in \bar{R}} \ \text{
u.c. } \ \prob{ \psi_R(X) \neq Z , \  X\in R } \leq \alpha .
\end{eqnarray}
\begin{proposition}\label{Prop:MNPR classification region}
    \blue{If $MNPR(\psi_{\mathcal{X}})\leq \alpha$, then $R^*=\mathcal{X}$ is a solution
    of ~\eqref{eq:MNPRpb}. Otherwise,
    any $R^*$ satisfying $MNPR(\psi_{R^*}) = \alpha$ and
 
  such that
\begin{eqnarray}
\gacc{ \ x \ \left|\
  \frac{\sum_{k=1}^K \tau_k(x)}{1-\tau^*_K(x)}> \lambda \right. } \ \subseteq \ R^* \ \subseteq \ \gacc{ \ x \ \left|\
  \frac{\sum_{k=1}^K \tau_k(x)}{1-\tau^*_K(x)}\geq \lambda \right. }  ,
  \label{Equ : OptimalRule-NP-KinfP }
\end{eqnarray}
for some $\lambda\geq 0$, is a solution of~\eqref{eq:MNPRpb}.}

\blue{If the marginal distribution of $X$ is without atoms,
there exists $R^*$ satisfying the above conditions.}


In the particular case where $K=P$,
\blue{condition~\eqref{Equ : OptimalRule-NP-KinfP } can be reduced to:}
\begin{eqnarray}
\gacc{ \ x \ \left| \
  \tau^*(x) > \lambda \right. } \  \subseteq \
  R^* \ \subseteq \ \gacc{ \ x \ \left| \
  \tau^*(x) \geq \lambda \right. } .
 
  \label{Equ : OptimalRule-NP-KequP }
\end{eqnarray}
\blue{for some $\lambda\geq 0$.}
\end{proposition}
The proof is based on the original proof of the Neyman-Pearson theorem, \cite{neyman1933ix}, and can be found in Appendix A.


\subsection{Optimal classification region for MFDR control} \label{Subsect : MFDR control}
If all classes are of interest, one looks for a region $R^*$ such
that
\begin{eqnarray*}
R^* \in \underset{R}{\arg\min}\ P\gp{X\in \bar{R}} \ \text{ u.c. } \ \prob{ \psi_R(X) \neq Z | \ X\in R } \leq \alpha.
\end{eqnarray*}
If $K<P$, $R^*$ should satisfy
\begin{eqnarray}
R^* \in \underset{R}{\arg\min}\ P\gp{Z\in\{1,\ldots,K\} , \  X\in \bar{R}} \ \text{
u.c. } \ \prob{ \psi_R(X) \neq Z| \ X\in R } \leq \alpha.
\label{eq:MFDRpb}
\end{eqnarray}
\begin{proposition}\label{Prop:MFDR classification region}
\blue{If $MFDR(\psi_{\mathcal{X}}) \leq \alpha$, then $R^*=\mathcal{X}$
  is a solution of~\eqref{eq:MFDRpb}. If $\tau^*_K(X)<1-\alpha$ almost surely, then $R^*=\emptyset$ is a solution of~\eqref{eq:MFDRpb}.}
  
\blue{Otherwise, any $R^*$ satisfying $MFDR(\psi_{R^*}) = \alpha$ and
 
  such that
\begin{eqnarray}
  \gacc{ \ x \ \left|\
  \frac{1-\alpha-\tau^*_K(x)}{\sum_{k=1}^K\tau_k(x)}< \lambda \right. }
  \ \ \subseteq \ \ R^*  \ \ \subseteq \ \
\gacc{ \ x \ \left|\
\frac{1-\alpha-\tau^*_K(x)}{\sum_{k=1}^K\tau_k(x)} \leq \lambda \right. } , \label{Equ : OptimalRule-FDR-KinfP}
\end{eqnarray}
for some $\lambda\geq 0,$ is a solution of~\eqref{eq:MFDRpb};
if the marginal distribution of $X$ is without atoms, such an $R^*$
exists.}

\blue{In the case $K=P$, 
condition~\eqref{Equ : OptimalRule-FDR-KinfP} can be reduced to:}
\begin{eqnarray}
\gacc{ \ x \ \left| \ \tau^*(x)>
  1-\alpha-\lambda \right. }
  \ \ \subseteq \ \ R^* \ \ \subseteq \ \
  \gacc{ \ x \ \left| \ \tau^*(x) \geq
  1-\alpha-\lambda \right. } \ ,
  \label{Equ : OptimalRule-FDR-KequP}
\end{eqnarray}
\blue{for some $\lambda \geq 0$.}
\end{proposition}
The proof of Proposition \ref{Prop:MFDR classification region} can be found in Appendix B. \gb{In the case $K=P$, 
the optimal region takes the form of a thresholded rule~\eqref{Def : Thresholded rule} for an appropriate threshold. This was
observed by \cite{denis2020} who studied optimal rules for
the MFDR/coverage tradeoff in the case
$K=P=2$. Interestingly, when $K<P$, the optimal rule is 
different from a simple threshold rule.}


The form of the optimal region $R^*$ in~\eqref{Equ : OptimalRule-NP-KequP },~\eqref{Equ : OptimalRule-FDR-KinfP}  is $C_{<\lambda} \subseteq R^* \subseteq C_{\leq \lambda}$, where $C_{<\lambda},C_{\leq\lambda}$ are sublevel sets  (in the sense of strict, resp. non-strict inequality)  of a criterion depending on the posterior probabilities at point $x$. This ``sandwiching'' relation is  theoretically relevant in situations where $\prob{C_{<\lambda}} < \prob{C_{\leq \lambda}}$, for example if  the criterion used is piece-wise constant, and the level set at value $\lambda$ has nonzero probability.  In this situation, strictly speaking to achieve exactly the target MNPR or MFDR rate, $R^*$ should only include  part of the level set at value $\lambda$ (and this part can be chosen arbitrarily provided the constraint is satisfied). \blue{The assumption of atom-free $X$-marginal could also be lifted to grant the existence of optimal rules in general, provided randomized rules are allowed, as in classical Neyman-Peason theory.} Since such situations are obviously of little relevance for most applications, in the remainder of this work, to simplify exposition we assume that $\prob{C_{<\lambda}} = \prob{C_{\leq \lambda}}$ and that $R^*$ exactly coincides with a sublevel set.

\subsection{Comparison between thresholded rule and the MFDR-optimal rule}
The restriction region $R_\alpha$ of the thresholded rule \eqref{Def : Restricted Thresholded rule} can now be compared to the MFDR-optimal regions $R^*$ found in the previous section. One has
\begin{eqnarray*}
R_\alpha &=& \{x \left| \tau^*_K(x)\geq1-\alpha \right.\} \text{ with } K \leq P, \\
R^* &=& \left\{x | \tau^*_K(x)\geq 1-\alpha - \lambda\sum_{k=1}^K\tau_k(x) \right\} \text{ with } \lambda \geq 0 \text{, if } K \leq P.
\end{eqnarray*}

According to the shape of $R^*$, the threshold for classifying an observation $x$ based on the maximal posterior probability $\tau^*_K(x)$ depends not only on $\alpha$, but also on $\sum_{k=1}^K\tau_k(x)$, that is the probability of belonging to the overall group of populations of interest. When $K<P$ this can be interpreted as follows:
when $\tau^*_K(x)$ is mild, the optimal rule may still classify $x$ if the probability of $x$ to belong to the overall group of the populations of interest is high. This interesting feature is not accounted for
in the thresholded rule that classifies an observation only based on $\tau^*_K(x)$. In this sense, the thresholded rule is not based on the appropriate classification criterion when one is interested only in a subset of all possible populations. \\
More generally, one can observe that whatever the number of populations of interest, both $\psi_{R^*}$ and $\psi^\alpha$ classify observations based on $\tau^*(x)$, but using a threshold that is always lower for $\psi_{R^*}$. \blue{Consequently i) the MFNR will always be higher for $\psi^\alpha$, and ii) the MFDR of $\psi^\alpha$ will be lower than the requested nominal level, i.e. the thresholded rule is a \emph{conservative} classification strategy to control the MFDR at level $\alpha$}. In Section \ref{Sect : Applications} we illustrate on simulated and real data the fact that the gap in term of MFNR between $\psi_{R^*}$ and $\psi^\alpha$ may be high.\\




\subsection{Estimation of parameter $\lambda$}\label{Subsect: EstimationOfLambda}

We present here an heuristic strategy to choose $\lambda$ from the data at hand.
First note that all optimal regions defined in Sections~\ref{Subsect : MNPR control} and~\ref{Subsect : MFDR control} are of the form of level sets
$$R^* = \gacc{ \ x \ \left|\
Crit(x) > \lambda \right. }, $$ where  $Crit(x)$ is a criterion based on the posterior probabilities at point $x$, that depends on the risk one wants to control and on the number of classes of interest as follows:\\
$\star$ if one aims at controlling the MNPR then
$$ Crit(x) = \frac{\sum_{k=1}^K \tau_k(x)}{1-\tau^*_K(x)}\ (\text{case } K<P )\quad \text { or }\quad Crit(x) =\tau^*(x) \ (\text{case } K=P), $$
$\star$ if one aims at controlling the MFDR then
$$ Crit(x) = \frac{\tau^*_K(x)+\alpha-1}{\sum_{k=1}^K\tau_k(x)}\ (\text{case } K<P )\quad \text { or }\quad Crit(x) =\tau^*(x)+\alpha-1 \ (\text{case } K=P) $$
where $\lambda\leq 0$.


Assuming an $n$-sample $D_n=(X_1,\ldots,X_n)$ is available, the MNPR and MFDR can be estimated for any region $R$ by
\begin{eqnarray*}
&&\hatprob{ \psi(X) \neq Z ,\ \ X\in R } = \frac{1}{n}\sum_{X_i \in R} (1-\tau^*_K(X_i))\\
\text{ and }&& \hatprob{ \psi(X) \neq Z | \ X\in R } = \frac{1}{n_R}\sum_{X_i \in R} (1-\tau^*_K(X_i))
\end{eqnarray*}
respectively, where $n_R$ is the number of observations in $D_n$ belonging to $R$ (and we recall that $\tau^*_K(x)=\tau^*(x)$ if $K=P$). This leads to the following general heuristic for the evaluation of threshold $\lambda$:
\begin{algorithm}[H]
\begin{algorithmic}
\Require $\alpha$, $x_1,\ldots,x_n$
\State 1/ Order observations $x_1,\ldots,x_n$ according to $Crit(x_i)$:\\ \vspace{0.3cm}
\hspace{2cm}$Crit(x_{(1)})\geq\ldots\geq Crit(x_{(N)})$,
\State 2/ Find the largest index $i_{max}$ such that $\displaystyle{\frac{1}{M(i_{max})}\sum_{i=1}^{i_{max}} (1-\tau^*_K(x_{(i)})) \leq \alpha}$,
\State 3/ Set $\widehat{\lambda} = Crit(x_{(i_{max})})$,
\State 4/ Output $\widehat{\lambda}$.
\end{algorithmic}
\caption{}
\label{Algo: Forward}
\end{algorithm}
If the goal is to control MFDR, then in the second step of the heuristic $M(i_{max})=i_{max}$, otherwise $M(i_{max})=n$ for a MNPR control.


