# Correct $p$ value for a t-test

I have two groups and I computed the t-test (both sides, $\alpha$=0.05) on them. The result shows significance difference between the means of two groups.

Now I want to know which group has a higher mean, hence I want to repeat my t-test but this time only one side (e.g. right tail).

First of all is this way correct to find out which mean is higher? Second, do I have to use $\alpha/2$,i.e., $\alpha$=0.025 this time?

• The group with the higher mean is the one with ... the higher mean. Conducting a new test is pointless. – whuber Sep 13 '16 at 22:49

You have the estimates of the population means (or can just compute them from the data again if the stats software you used doesn't report them). By definition the group with the larger/higher population mean is the group with the higher mean in the test.

You shouldn't repeat the test but using a one-sided hypothesis once you know the outcome of the two-sided test. Just compute the sample means for the groups from the data and you have all you need to know with the first $t$ test.

For example (using R and some dummy data with known different means):

set.seed(1)
df <- data.frame(x = rnorm(100, mean = c(-5, 5)),
grp =  factor(rep(c("A", "B"), times = 50)))
t.test(x ~ grp, data = df)


In R we get:

> t.test(x ~ grp, data = df)

Welch Two Sample t-test

data:  x by grp
t = -54.683, df = 97.885, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-10.183345  -9.470102
sample estimates:
mean in group A mean in group B
-4.804474        5.022249  <------ Group sample means


So we can clearly see which group has the larger mean. But if we didn't get that in the output in whatever stats software we're are using, just proceed by computing the groups means. Here I do it the slow way (better R code is available)

with(subset(df, grp == "A"), mean(x))
with(subset(df, grp == "B"), mean(x))

> with(subset(df, grp == "A"), mean(x))
[1] -4.804474
> with(subset(df, grp == "B"), mean(x))
[1] 5.022249


So even if we don't know from the test which group had the higher mean we can always find it from the sample means (estimates of the population means).

(Nicer R code might include:

> aggregate(x ~ grp, data = df, FUN = mean)
grp         x
1   A -4.804474
2   B  5.022249


.)

• Thanks a lot for the answer. It's very helpful. Just one more question. Could you please explain why it is wrong to repeat the test by using a one-sided hypothesis. – Mina Sep 13 '16 at 23:39
• @Mina Because it's pointless to repeat when you already know which group has higher mean. Statistics can't tell you anything that you already don't have. It's a waste of time and the computer's electricity. – SmallChess Sep 13 '16 at 23:44
• I am asking this question because I came across with some examples (unfortunately I don't have right now), where t-test shows significance difference but when I compute the sample means of two groups they are equal. Then in these cases I don't know which group has a higher mean just by computing the sample mean. – Mina Sep 13 '16 at 23:56
• @Mina those examples you think you have seen are not possible (at least not the way you describe); the numerator of the t-statistic (the difference in sample means) will be zero, so the t statistic will be 0; the p-value even for a one tailed test will not be lower than 0.5 and so will not be significant at any ordinary $\alpha$ ... I'd be very interested to know what you actually saw. – Glen_b Sep 14 '16 at 0:21
• I see. If I find those examples I'll post it here. Thanks – Mina Sep 14 '16 at 0:44