Wrong confidence interval in R I have independent 2 samples (both with $n = 200$) and i want to show that the true mean of sample b is higher than the true mean of sample a i.e. $H_0 : \mu_B \le \mu_A$ and $H1: \mu_B \gt \mu_A$.
I wanted to conduct a two sample t-test but since the true mean and variance are unknown i did a F-Test beforehand. The results of the F-Test were, that $\sigma^2_A = \sigma^2_B$.
Because of that i ran the aforementioned t-test in R with following parameters:
t.test(B,A, alternative="greater", var.equal = TRUE, paired=FALSE, conf.level=0.95) 
output:
           Two Sample t-test
data:  B and A
t = 0.33934, df = 398, p-value = 0.3673
alternative hypothesis: true difference in means is greater than 0
95 percent confidence interval:
 -1062.14      Inf
sample estimates:
mean of x mean of y 
 8545.895  8270.625 

I calculated the test-value by hand and had the same result for t. The means of A and B are correct too, but i dont understand the confidence interval. As far as i know the critical value for a right sided test is $t_{398;0.95} = 1.649$ and because of that id keep the null hypothesis since $t = 0.3393 \ngtr 1.649$. But if i were to follow the confidence interval in R id have to reject it, which seems odd.
 A: The result from R says you don't reject the null.
The result gives you the confidence interval of the difference.  It says $-1062.14 \lt \mu_B-\mu_A \lt \infty$.  That means $\mu_B$ could be less than $\mu_A$ and so you cannot reject the null hypothesis.
A: Just to add to/expand on @abstrusiosity's answer:

*

*As mentioned above, 0 falls between -1062.14 and Inf - so if you were using the confidence interval to make null hypothesis testing decisions you would fail to reject the null in this case. (assuming the null is that the difference is not different from 0).

*The Inf is a result of your one-sided test. You don't really care about the upper bound of the CI in a > one-sided test - just that the lower bound is above 0. You get the same behavior with one-sided tests in the opposite direction. If you run the code below, you'll get -Inf on the lower bound of the interval when the directionality of the test is reversed.

A <- rnorm(100)
B <- rnorm(100)
t.test(A, B, alternative = 'less', var.equal = TRUE, paired = FALSE, conf.level = .95)



*If you want the symmetrical 95% CI you can run the code below. This CI would map on to a two-sided p-value.

# I've omitted `alternative` as the default is "two-sided"
t.test(A, B, var.equal = TRUE, paired = FALSE, conf.level = .95)

You can change the interval to .90 to get the LB or UB relevant for your directional hypothesis and get a symmetrical confidence interval around the mean difference.
