# Defining extremeness of test statistic and defining $p$-value for a two-sided test

Our tag definition of the $$p$$-value says

In frequentist hypothesis testing, the $$p$$-value is the probability of a result as extreme (or more) than the observed result, under the assumption that the null hypothesis is true.

But how do we define what is more extreme? In "A Dialog Between a Teacher and a Thoughtful Student", @whuber shows that extreme can be defined w.r.t. the likelihood ratio under $$H_0$$ vs. $$H_1$$ (or $$H_A$$ in the original notation), $$LR=\frac{P(data|H_1)}{P(data|H_0)}$$. The larger the LR, the more extreme the result. So far so good.

In @whuber's example, $$H_0$$ is one-sided, and so is $$H_1$$. Then it is not so difficult to find which regions of values of the test statistic produce the largest LRs. Thus we have little conceptual trouble in finding the $$p$$-value; we just integrate the area under the null distribution for all possible values of the test statistic that are equally or more extreme (have equal or larger LR) than the observed value.

However, it is not so clear when $$H_1$$ is two sided, such as in a two-sided $$t$$-test. While the left tail of the null distribution would produce the largest LRs for an alternative to the left of the hypothesized value in $$H_0$$, the left tail would not at all be extreme for an alternative to the right of $$H_0$$; in fact, it would be the opposite tail that would be extreme. The problem is, both alternatives belong to $$H_1$$.

Q: How do we deal with such a situation? What is the principled way of defining extremeness when contradicting levels of LRs can arise under different instances within $$H_1$$?

P.S. I have earlier asked a related question of whether $$p$$-value ever depends on the alternative. I learned that using the modern (post Fisher) definition of the $$p$$-value, it does.

Update: I have received a few good answers, but I am still struggling with the intuition: see my comment.

• As with many questions about p-values, it can help if you start from a Neyman-Fisher type approach, where we have a rejection rule at some significance level (but not necessarily LRT*). Then "more extreme" is a consequence of specifying a choice of rejection regions. If you define a set of nested rejection regions (sets) $R_i$ at a sequence of increasing significance levels (so that $R_i\subset R_{i+1}$ for $\alpha_{i+1}>\alpha_i$. Then test statistics in $R_i$ are more extreme that test statistics that are in $R_{i+1}$ but not in $R_i$. ... ctd Aug 19, 2020 at 9:33
• ctd .. * e.g. LRT is no use when you don't have a parametric distributional model. So, for example, if we do a two-sided two-sample permutation test of difference in means and specify our test statistic as $\bar{x}-\bar{y}$, then we might proceed to construct rejection regions by considering $|\bar{x}-\bar{y}|$ which gives us just such a set of nested rejection regions; and so "more extreme" $\bar{x}-\bar{y}$ is then "larger $|\bar{x}-\bar{y}|$". Other choices are possible, though. Aug 19, 2020 at 9:43
• @Glen_b, thank you! I suppose the real question is, how do we define these rejection regions? How do we come up with a sensible rule for that? Also, does the essence of the problem change if we use LR vs. something else? I used the LR example as I found whuber's explanation quite clear. I think it would be helpful to stick to it for simplicity and for being able to relate to something that is already clear. Aug 19, 2020 at 9:53
• While it seems that we're just "shifting the problem", we do actually make it easier (specifically, less abstract) by considering the rejection region directly in the context of our specific situation/working hypothesis - which usually tells us what's "more consistent" with H1 (& which might sometimes vary from application to application even with the same test statistic). I wouldn't choose to only write an answer in terms of likelihoods or ratios of them for the reason I already gave -- it doesn't deal with a large subset of real testing situations where we don't have a parametric model. Aug 19, 2020 at 10:07
• the problem with just doing the two-sample t-test (mean-shift in a permutation test) situation is all the reasonable ways of looking at it (including both working with the natural pivotal quantity and using LRT at the normal) will all give the same definition of "more extreme"; it doesn't present the cases that typically cause difficulty. It's the cases where things are not so neatly symmetric that we must think more carefully and consider some alternatives. For one example, consider instead a two-sample equality of means (scale parameter) for times (possibly from an exponential distribution) Aug 19, 2020 at 11:39

Defining extremeness of test statistic and defining p-value for a two-sided test...

I would suggest that an appropriate perspective here is that, when one has the "right" statistic, the statistic itself tells you what "extremeness" means for the test problem at hand---one-sided or two-sided. The more basic question is therefore what the "right" statistic is. Test problems are special cases of optimization problems---you want to maximize power subject to size constraint. So this means defining the "right" solution concept.

For example, finding the most powerful test for the test problem with a simple null vs. simple alternative is a special case of a linear program: $$\sup_{0 \leq \phi \leq 1, \, \\ \\ \int \phi(\omega) f_0(\omega) d\mu \leq \alpha} \int \phi(\omega) f_1(\omega) d\mu.$$ It is a general fact that a solution $$\phi^*$$for any such program takes the form $$\phi^* = \begin{cases} 1 & \text{if } f_1 \geq k f_0 \\ 0 & \text{if } f_1 \geq k f_0, \end{cases}$$ for some $$k$$. In the context of a test problem, a natural interpretation is then that one rejects when the likelihood ratio statistic $$\frac{f_1}{f_0}$$ is larger than $$k$$.

(It is suggested in the comments that the threshold $$k$$ is interpreted to be the "shadow price" of the size constraint. Apparently this terminology is borrowed from economics. $$k$$ is the Kuhn-Tucker-Lagrange multiplier of the problem. For interior solutions, typically one would say that if $$\alpha$$---the budget, in economic problems---is relaxed by $$\epsilon$$, the power of the test increases by $$k \epsilon$$. This interpretation, however, does not really hold for linear programs in general.)

Similarly, finding a most powerful test of composite null vs. simple alternative amounts to solving a linear program. The solution to the corresponding dual program tells us that the most powerful statistic is a likelihood ratio statistic with respect to the least favorable Bayesian prior on the null. (The simple null case is a special case, with trivial prior.)

Tests with one-sided alternatives for models with monotone likelihood ratio (MLR) property is of course another example. MLR means the model admits a ranking of likelihood ratios that's invariant with respect to data $$\omega$$. So the likelihood ratio test is a most powerful test, almost by assumption.

For two-sided alternatives, e.g. $$\Gamma_0 = \{\gamma_0\}$$ and $$\Gamma_1 = (-\infty,\gamma_0)\cup (\gamma_0, \infty)$$ for normal densities parametrized by mean $$\gamma \in \mathbb{R}$$, the most powerful test does not exist in general. Therefore the right statistic needs to be determined by some other criterion---e.g. one can instead look for a locally most powerful test.

A test $$\phi^*$$ is a locally most powerful test if for any other test $$\phi$$, there exists an open neighborhood $$N_{\gamma_0, \phi}$$ of the null hypothesis such that $$\phi^*$$ has uniformly higher power than $$\phi$$ on $$N_{\gamma_0, \phi}$$. The corresponding first-order optimality condition gives the criterion $$\phi^* = \begin{cases} 1 & \text{if } \frac{\partial^2}{\partial \gamma^2}f_{\gamma_0} \geq k_1 \frac{\partial}{\partial \gamma} f_{\gamma_0} + k_2 f_{\gamma_0} \\ 0 & \text{if } \frac{\partial^2}{\partial \gamma^2}f_{\gamma_0} < k_1 \frac{\partial}{\partial \gamma} f_{\gamma_0} + k_2 f_{\gamma_0} \end{cases}$$ for some $$k_1$$ and $$k_2$$. Substituting the normal density into above expressions, we have that $$\phi^*$$ rejects when $$|x- \gamma_0|$$ is large---a two-sided test.

• Thank you for your answer! It is is more technical than I am comfortable with, but I will try to digest it. I would also love to get some more intuition. Sep 10, 2020 at 6:09
• @RichardHardy The FOC for two-sided $\phi^*$ probably has an interpretation---"if the likelihood under the null is sufficiently convex with respect to parameter, you reject the null". There is a Fisher-information flavor to the condition. Sep 10, 2020 at 6:15
• @RichardHardy Also, if we extend the Neyman-Pearson setting to a null with two elements $f_{0,1}$ and $f_{0,2}$, then the LR test extends to a statistic that rejects when $f_1$ is larger than $k_1 f_{0,1} + k_2 f_{0,2}$ for some $k_1$ and $k_2$. Perhaps the shadow price interpretation is useful here(?). Sep 10, 2020 at 7:05
• I am back to learning about $p$-values and now also LR tests. I have flipped through a few textbooks and then reread your answer and found it easier to understand. Some bits are still tough: The solution to the corresponding dual program tells us that the most powerful statistic is a likelihood ratio statistic with respect to the least favorable Bayesian prior on the null. Also, Therefore the right statistic needs to be determined by some other criterion---e.g. one can instead look for a locally most powerful test. This feels like a way of circumventing the problem rather than solving it. Jan 27, 2021 at 14:19
• (I am not blaming the conventions on you, though.) I think the definition of the $p$-value should be changed because it is ambiguous as it is now. It was not a problem in Fisher's paradigm where the $p$-value was defined w.r.t. to $H_0$ alone without reference to $H_1$, but it is a problem in its current form unless we are considering simple null vs. simple alternative, simple null vs. composite alternative where MLR holds, and a few other special case. Jan 27, 2021 at 14:23

In addition to scenarios in two-sided tests, this question arises in a less avoidable way in group sequential clinical trials.

In a group sequential trial there are a set of analysis times, and a stopping boundary specifying thresholds at each analysis for the trial to stop. In calculating $$p$$-values or confidence intervals it is necessary to specify a ordering of the possible outcomes. For example, if you stop at time 2 out of 4 with a $$Z$$-score of 3, how does that compare to stopping at time 3 with a $$Z$$-score of 2.5?

Among the orderings actually proposed are

• ordering by the magnitude of difference
• ordering by time, so that any stopping at an earlier time is more extreme than any stopping at a later time

These are genuine choices; different people could legitimately pick different orderings. Ordering by the magnitude of difference tends to lead to narrower confidence intervals, more accurate p-values, and less bias, but it increases the sensitivity of the analysis to the (unobservable) times at which future analyses of a stopped trial would have occurred.

(Reference: short course by Kittleson and Gillen)

• Thank you for your answer! It seems to focus on sequential trials, but does it answer the rather basic question I have asked? E.g. in a two-sided t-test, the practice seems to be that both tails are considered extreme; I am wondering what the basis for that is. More generally, without specifying a prior, how do we know which instances within the alternative to pick for defining extremeness? As I argue in the OP, different instances yield very different regions of extreme values, so the choice is important. Sep 1, 2020 at 7:07

## The answer to this question is what defines the particular test

But how do we define what is more extreme?

This choice is really the essence of what defines the particular hypothesis test under use. Indeed, a classical hypothesis test can be reduced to a specification of a total order $$\preceq$$ on the set of possible outcomes for the observable data. This total order, which I will call an evidential ordering, defines an ordering of which observable outcomes are more conducive to the null hypothesis and which are more conducive to the alternative hypothesis (i.e., "more extreme").

Suppose we have an observable data vector $$\mathbf{x} \in \mathscr{X}$$ from a model $$f_\theta$$ and we define hypotheses $$H_0: \theta \in \Theta_0$$ and $$H_A: \theta \in \Theta_A$$. Now suppose we choose an evidential ordering $$\preceq$$ on the set $$\mathscr{X}$$, where larger values in the ordering are regarded as being more conducive to the alternative hypothesis. Then we can define the p-value function for the corresponding hypothesis test as:

$$p(\mathbf{x}) = \sup_{\theta \in \Theta_0} \mathbb{P}( \mathbf{x} \in \mathcal{H}_A(\mathbf{x}) | \theta) \quad \quad \quad \mathcal{H}_A(\mathbf{x}) \equiv\{ \mathbf{x}' \in \mathscr{X} | \mathbf{x} \preceq \mathbf{x}' \}.$$

Since the hypothesis test is fully defined by its p-value function, and since this function is fully determined by the evidential ordering, the evidential ordering fully defines the test. Two hypothesis tests are equivalent if they use the same total order $$\preceq$$ (e.g., the T-test and F-test in a linear regression are equivalent if there is only one explanatory variable). In practice, the evidential ordering is usually defined only implicitly through the formation of a test statistic $$T:\mathscr{X} \rightarrow \mathbb{R}$$ and a specification of an ordering on $$\mathbb{R}$$. Nevertheless, the test statistic is really just a mechanism to define the underlying evidential ordering, and two different specifications of test statistics that lead to the same evidential ordering essentially define the same test.

Now, we can make different choices of the evidential ordering and this defines different hypothesis tests. We can then explore the properties of those tests ---e.g., their power function, etc.--- to see which orderings lead to tests with good properties. Finding a good ordering that yields good properties for the test is an art form in itself, but the general idea is that we usually try to form a statistic that tends to be "small" when the null hypothesis is true, and gets larger the further we depart into the alternative hypothesis. The likelihood-ratio statistic you use in your question is a statistic that has this property, but there are others as well. As to how to generalise the likelihood ratio statistic to composite hypotheses, the usual generalisation is:

$$R(\mathbf{x}) = \frac{\sup_{\theta \in \Theta_A} f_\theta(\mathbf{x})}{\sup_{\theta \in \Theta_0} f_\theta(\mathbf{x})}.$$

As you can see, this statistic defines "extremeness" by looking at the constrained maximised likelihood within each composite hypothesis. Other generalisations are of course possible, and it is open to you to formulate an alternative test statistic leading to a different test (through a different evidentiary ordering).

Trying to clear up your confusion: From what you have written in your question, I think this issue here is a failure to understand why we use "two-sided" hypothesis tests (or statistics like the LR statistic) that count unlikely deviations in any direction as being conducive to the alternative hypothesis. The reason for this is that we are usually a priori ignorant of the likely direction in which extreme deviations might occur. If we first observe the data and then see which tail it is in, and then choose a "one-sided" alternative in that direction, we are essentially altering the evidential ordering after seeing the data. This induces serious confirmatory bias in the test, since the alternative hypothesis is formulated after seeing the data in a way that treats deviations in the observed direction to be conducive to the alternative.

For example, if we have a symmetric distribution and we use a post hoc one-sided test, we essentially halve the p-value (it is now uniformly distributed between zero and a half). This imposes serious confirmatory bias, and it means that the stipulated size of the test is actually only half the true size.

• Thank you for your answer! It does make sense on its own. However, I would like to gain intuition about what is wrong with my apparently wrong thinking. My core difficulty seems to be going from a point alternative to a set alternative. For a point alternative, I understand which values of the statistic have higher or lower LRs. For a set alternative, I also do understand that there exists a point in the set for which the likelihood is maximized, and then we could take that point as the point and proceed. However, what permits us to take that point? Jan 14, 2021 at 7:59
• It feels like drawing the target after the shot. Let $H_0$ be that I am aiming at a prespecified target $\theta_0$. Let $H_1$ be that I am aiming somewhere else, either to the left or to the right of $\theta_0$. Suppose in reality, I am aiming at $\theta_1>\theta_0$. I make a shot and hit $\hat\theta<<\theta_0$. An arbiter is called to decide whether I was aiming at $\theta_0$ or not. The arbiter has an estimate of my precision $\hat\sigma$ from earlier shooting competitions. Since $\hat\theta$ is far away from $\theta_0$ in terms of $\hat\sigma$, the arbiter says it is highly unlikely... Jan 14, 2021 at 8:00
• ...I was aiming at $\theta_0$ and thus I must have been aiming at $\theta_2$ such that $\theta_2<\theta_0$. Note that it is values to the left of $\theta_0$ that favor the observed shot. The arbiter uses a LR test to support his decision formally. Now the arbiter got the right answer for the wrong reason. The LR of $\theta_0$ vs. $\theta_1$ would have suggested to stick to $H_0$. But the opportunistic choice of $\theta_2$ after seeing the data allowed the arbiter to use the LR of $\theta_0$ vs. $\theta_2$ to measure extremeness (in the wrong tail) and deem $H_0$ way too unlikely to retain. Jan 14, 2021 at 8:06
• It is not so much that there is anything that permits us to use this statistic --- it is simply that if we decide to choose this statistic then we get a hypothesis test with a reasonable evidentiary ordering and it has some okay properties. It is certainly legitimate for us to form other test statistics and then check if that gives better properties for the hypothesis test, but this one yields some reasonable results. There is a reasonable intuition behind the LR statistic, notwithstanding your objection, but if you think you can formulate a better ordering, give it a go.
– Ben
Jan 14, 2021 at 8:10
• Thank you. I wish I could engage you in pointing out my mistake and straightening out my intuition (I have been struggling with this problem for quite a while now), but your current answer is appreciated nonetheless. Jan 14, 2021 at 8:21

Not taking it further than likelihood ratios ...

$$\renewcommand\vec{\boldsymbol}$$ The generalized likelihood ratio, for a test of the null hypothesis $$\vec\theta \in \Theta_0$$ vs the alternative $$\vec\theta \in \Theta_\mathrm{A}$$ is

$$\renewcommand\vec{\boldsymbol} \frac{\sup_{\vec{\theta} \in \Theta_\mathrm{A}} \left[f(\vec{x}; \vec\theta)\right]}{\sup_{\vec{\theta} \in \Theta_0} \left[f(\vec{x}; \vec\theta)\right]}$$

& for simple, i.e. fully specified, null ($$\vec\theta = \vec\theta_0$$) & alternative ($$\vec\theta=\vec\theta_\mathrm{A}$$) reduces to the ordinary likelihood ratio. On the face of it, it's a reasonable measure of extremeness: the ratio of the likelihood of the most likely parameter values consistent with the alternative to the likelihood of the most likely parameter values consistent with the null.

A typical two-tailed test for a scalar $$\theta$$ of the null $$\theta=\theta_0$$ vs the unrestricted alternative $$\theta \in \Theta$$ would use

$$\frac{f(\vec{x}; \hat\theta)}{f(\vec{x}; \theta_0)}$$

where $$\hat\theta$$ is the maximum-likelihood estimate; with the test statistic increasing as $$\hat\theta$$ moves away from $$\theta_0$$ in either direction. For the mean of a Gaussian distribution, with known variance, that's

$$\frac{f(\vec{x}; \bar x, \sigma^2)}{f(\vec{x}; \mu_0; \sigma^2)}$$

(where $$f(\cdot)$$ is the Gaussian density function). When the variance is unknown, i.e. a nuisance parameter, the generalized likelihood ratio becomes

$$\frac{f\left(\vec{x}; \bar{x}, \frac{\sum(x-\bar{x})^2}{n}\right)}{f\left(\vec{x}; \mu_0, \frac{\sum(x-\mu_0)^2}{n}\right)}$$

These equate to the z- & t-statistics—to @Glen_b's point, any sensible test statistics for these cases will.

Note that the generalized likelihood test doesn't in general enjoy any optimal power properties for small samples. It may be uniformly most powerful (though not for a two-tailed test—see @Michael's answer), locally most powerful (i.e. it coincides with Rao's score test—see @Michael's answer again), uniformly most powerful among unbiased tests, or at least admissible; but it may be inadmissible, or even "worse than useless". (For large samples, given some regularity conditions, Wilks' Theorem applies.)

† More often called just the "likelihood ratio test"; perhaps because in practice testing of point vs point hypotheses is rare & there's little need for the distinction.

• Thank you for your answer. It has not quite given med the intuition I am seeking (at least on the first two reads) but it is appreciated nonetheless. In case you have some more patience with me, see thee comments I have just posted under Ben's answer; they apply also here. Jan 14, 2021 at 8:25
• After reading about hypothesis testing, UMP tests, UMP unbiased tests and LR tests in several textbooks, I got the impression that the definition of $p$-value is not unambiguous and perhaps not very meaningful unless we are testing a point null vs. a point alternative and perhaps (?) when a UMP test exists and the LR is monotonic. The problem is not with the statistical machinery (it is fine) but with the precise definition of the $p$-value. The crucial point of what is in favor of a set and what is not has not been satisfactorily addressed in the treatments I have encountered. Jan 27, 2021 at 14:45
• So you were right that Your preceding comment perhaps gets to the nub of the issue better than the question. This is an intermediary conclusion; I will continue reading and thinking about it. Thank you for posting your answer (+1) and engaging in the discussion in the comments. Jan 27, 2021 at 14:48
• @RichardHardy: It's more conventional, & neater, to say the p-value, given a sample space & a test statistic that partitions & totally orders it, is unambiguously defined; but that the analyst may have considerable latitude in the choice of sample space & test statistic. (The plethora of tests for homogeneity in a 2x2 table provides an informative example.) Jan 30, 2021 at 10:55