Cross post [Optimal hypothesis testing uses sufficient statistics?](https://math.stackexchange.com/questions/4647472/optimal-hypothesis-testing-uses-sufficient-statistics).


In statistical estimation with any convex risk for a model with a sufficient statistic, in seeking optimal estimators it suffices to consider functions of the sufficient statistic. This follows from (conditional) Jensen's inequality: if $g$ is an estimator for $\theta$ and $T=T(X)$ is a sufficient statistic, then $h(X)=E[g(X)|T]$ is an estimator of $\theta$ satisfying $R(h,\theta)\leq R(g,\theta)$ for all $\theta$, where $R$ denotes the risk.


My question is, does a version of this result hold in hypothesis testing? That is, the goal is to define a test (i.e. a function $\phi$ of the data with $\phi(X)\in\{0,1\}$ with optimality properties, say a good sum of type I and type II error, and the conclusion would be that it suffices to consider tests depending only on the sufficient statistic $T(X)$.
Note that directly applying the same argument doesn't give anything useful: $E[\phi(X)\mid T]$ is no longer a hypothesis test since it takes values in $[0,1]$.


References of any kind welcome: I suspect there may be lecture notes with some result of this kind, I just haven't been able to find any.



Optimal hypothesis testing uses sufficient statistics?
$\newcommand\th\theta\newcommand\Th\Theta$It is natural, standard, and convenient to allow randomized tests, with values in $[0,1]$, and then your objection will be removed: $E(\phi(X)|T)$ is a randomized test.


Recall that a Neyman--Pearson test for a simple null hypothesis $H\_0\colon\th=\th\_0$ vs. a simple alternative $H\_1\colon\th=\th\_1$, which is optimal at the level equal to its size, is based on the ratio
$$\frac{f\_{\th\_1}(x)}{f\_{\th\_0}(x)}=\frac{g(\th\_1,T(x))}{g(\th\_0,T(x))},\tag{1}\label{1}$$
which is a function of $T(x)$, where $(f\_\th)$ is the statistical model (that is, a family of probability densities with respect to a measure), $T$ is a sufficient statistic for this model, and $g$ is the function that enters the [Fisher–Neyman factorization](https://en.wikipedia.org/wiki/Sufficient_statistic#Fisher%E2%80%93Neyman_factorization_theorem)
$$f\_\th(x)=g(\th,T(x))h(x).$$
So, the (optimal) Neyman--Pearson test is a function of any sufficient statistic.
Note also that, if the model is discrete and the prescribed level of significance $\alpha$ of the test is an arbitrary number in $(0,1)$, then the (optimal) Neyman--Pearson test will usually **have to be randomized** -- see e.g. [this](https://stats.stackexchange.com/questions/560152/randomized-neyman-pearson-lemma-for-a-discrete-distribution).


Similarly to \eqref{1}, the likelihood ratio test for composite hypotheses $H\_0\colon\th\in\Th\_0$ vs. $H\_1\colon\th\not\in\Th\_0$ is based on the ratio
$$\frac{\sup\_{\th\in\Th\_0}f\_\th(x)}{\sup\_{\th\in\Th}f\_\th(x)}
=\frac{\sup\_{\th\in\Th\_0}g(\th,T(x))}{\sup\_{\th\in\Th}g(\th,T(x))},\tag{2}\label{2}$$
which is a function of $T(x)$, for any sufficient statistic $T$.


