Skip to course content
Free R statistics course

Statistical Data Analytics with R

Unit 05.03: The direction is part of the hypothesis

A one-sided test halves your p-value. That is exactly why it has to be chosen before you see the data.

The direction is part of the hypothesis

A two-sided test asks whether the parameter differs from the null value in either direction. A one-sided test asks only about one direction, and concentrates the whole rejection region there — which is why the p-value is half.

That halving is legitimate when the direction was specified in advance on substantive grounds, and it is a way of manufacturing significance when the direction is chosen after seeing which way the mean fell. Doing that makes the real false-positive rate 10%, not 5%.

A one-sided test also gives up the ability to detect an effect in the other direction. If the true effect is opposite to your hypothesis, the test reports a p-value near one and you conclude nothing.

This block runs all three forms on the same sample.

set.seed(2041)
d <- rnorm(30, mean = 106, sd = 12)

two_sided <- t.test(d, mu = 100)
greater   <- t.test(d, mu = 100, alternative = "greater")
less      <- t.test(d, mu = 100, alternative = "less")

cat("Sample mean:", round(mean(d), 2), "\n\n")
cat(sprintf("two-sided        p = %.4f\n", two_sided$p.value))
cat(sprintf("one-sided greater p = %.4f\n", greater$p.value))
cat(sprintf("one-sided less    p = %.4f\n", less$p.value))

cat("\nThe one-sided p in the observed direction is exactly half the two-sided:\n")
cat("  two-sided / 2 =", round(two_sided$p.value / 2, 4), "\n")
cat("  greater       =", round(greater$p.value, 4), "\n\n")

cat("That halving is why a one-sided test must be chosen BEFORE the data.\n")
cat("Choosing the direction after seeing which way the mean fell converts\n")
cat("a 5% false-positive rate into 10%.\n")
cat("A one-sided test also cannot detect an effect the other way:\n")
cat("  if the true effect were negative, 'greater' would report p near",
    round(1 - greater$p.value, 2), "\n")

The sample mean is 104.72. Two-sided gives p = 0.0320; one-sided 'greater' gives 0.0160, exactly half; one-sided 'less' gives 0.9840. The arithmetic is confirmed directly — two-sided / 2 = 0.016 = the 'greater' p-value. And the last line shows the cost: had the true effect been negative, the 'greater' test would have reported p near 0.98 and found nothing at all.

The mistake this prevents

The mistake is switching to a one-sided test when the two-sided p comes out at 0.07. It always works, and it is the clearest possible example of letting the data choose the hypothesis.

Takeaway

Default to two-sided. Use one-sided only when the direction was pre-specified for a substantive reason, record that in the analysis plan, and accept that you cannot then report an effect the other way.