# Confidence Interval's equivalence to hypothesis tests

Theoretically, I was having a debate with my friend about confidence intervals and I got confused.

So, my understanding is the whole confidence interval is essentially the same as a two-tailed hypothesis test.

So, a 95% confidence interval is essentially the same as a two-tailed hypothesis test with significance level 10%.

So for example, if you have

H0: μ = x

and H1: μ ≠ x

with significance level 10%

You could turn this into a z-statistic and do a hypothesis test, or you could set up a 90% confidence interval.

The problem for me, theoretically comes in with one-tailed.

So for example, if you have H0: μ < x, and you see that it lies in the confidence interval, but above the sample mean. Do you reject H0? Do you split the hypothesis test essentially down the sample mean and use x̄ > the lower half of the interval when it's a one-tailed test, and do the opposite if you want to see if the mean has increased?

• (1) You are right that there is often a duality btw a 2-sided test and a 2 sided CI, both with same 'error probability' $\alpha$ (with the CI containing 'non-rejectable' null values. An exception is with tests binomial proportion and Wald CIs.// (2) Although not always covered in elementary courses, there are 'one-sided CIs' that essentially give an upper or lower bound for the parameter value. I'll show results for a one-sided t test in R to illustrate. – BruceET May 5 at 17:46
• One possibly useful link from the right-hand margin. – BruceET May 5 at 18:57

Comment on One-sided t confidence intervals continued:

Start with a sample of 25 observations from $$\mathsf{Norm}(\mu = 100, \sigma=10):$$

set.seed(505)
x = rnorm(25, 100, 10)
mean(x);  sd(x)
## 97.0539         # sample mean
## 9.853215        # sample standard deviation


The sample mean is about $$\bar X = 97.05,$$ which is smaller than $$\mu_0 = 100.$$

Is that sufficient evidence to reject $$H_0: \mu = \mu_0 = 100$$ against the one sided alternative $$H_a: \mu < \mu_0?$$

t.test(x, mu = 100, alte="less")

One Sample t-test

data:  x
t = -1.495, df = 24, p-value = 0.07397
alternative hypothesis: true mean is less than 100
95 percent confidence interval:
-Inf 100.4254
sample estimates:
mean of x
97.0539


Because the P-value (about $$7.4\%)$$ exceeds 5%, we do not reject $$H_0: \mu = \mu_0$$ against the left-sided alternative at the 5% level of significance.

The left-sided 95% confidence interval is $$(-\infty, 100.4254).$$ This indicates that data are consistent with a true mean below $$100.4254.$$

For example, in terms of possible null values $$\mu_0:$$ We would not have rejected with $$\mu_0 = 100.4$$ or with $$\mu_0=99.2$$ (or any other hypothetical mean below $$100.4254.)$$

Below we show just the P-values for the two values of $$\mu_0$$ mentioned above:

t.test(x, mu = 100.4, alte="less")$p.val ## 0.05122181 # barely avoids rejection at 5% t.test(x, mu = 99.2, alte="less")$p.val
## 0.1434768      # not even close to rej at 5%


Note: A direct computation of the upper limit of the left-sided 95% CI shown in R's output for the t test above is as follows:

$$\bar X + t_U S/\sqrt{n},$$

where $$\bar X$$ and $$S$$ are the respective sample mean and standard deviation and $$t_U$$ cuts probability 5% from the upper tail of Student's t distribution with 24 degrees of freedom. This computes to $$100.4254.$$

t.u = qt(.95, 24); t.u
## 1.710882
mean(x) + t.u*sd(x)/sqrt(25)
## 100.4254