We now consider how to compute a p-value for a two-sided test. In one-sided tests, we shade the single tail in the direction of the alternative hypothesis. For example, when the alternative had the form , then the p-value was represented by the upper tail (Figure LABEL:pValueOneSidedSleepStudyExplained). When the alternative was , the p-value was the lower tail (Exercise 2.9.10). In a two-sided test, we shade two tails since evidence in either direction is favourable to .
Caution: One-sided hypotheses are allowed only before seeing data
After observing data, it is tempting to turn a two-sided test into a one-sided test. Avoid this
temptation. Hypotheses must be set up before observing the data. If they are not, the test
must be two-sided.