# How to calculate p-value for t-test if original data is not available? [duplicate]

I have two (normally distributed) samples:

First: n=50 mean=3 sd=2

Second: n=40 mean=3.5 sd=1.9

Is this enough to perform two-sample and two-sided Student's t-test with equal variances? If yes, how can I compute p-value in R? Function t.test() accepts only original data.

• See responses on this question Commented Jul 28, 2013 at 14:33

Yes, you can. Just plug-and-chug these values into the t-test formula. I'm going to assume the samples are independent, and this is an unpaired two-tailed test:

$t= \frac{\left | \bar{X_1} - \bar{X_2} \right |}{\sqrt{s_1^2 /n_1 + s_2^2 /n_2 }}$

Once you've calculated this t statistic, compare it against the appropriate t-value for the significance level you are testing for at $df = n_1 +n_2 - 2$. At $df = 88$, $t \geq 1.99$ gives a significance of $p \leq 0.05$ (via this t-table). In your case, $t=1.21$, so your sample means are not significantly different at the $p=0.05$ level.

If you need to calculate the exact p-value, instead of looking it up in a t-table you can use the r function for the $t$ CDF, pt(), which gives $p = 0.2288375$ for your data when you specify that you want the upper tail of the distribution (lower.tail=F) and double your result for a two-tailed test.

Here's the whole thing wrapped in a little function in case you have more similar tests to run:

homebrew_two_tailed_t_test = function(m1, m2, n1, n2, s1, s2){
t = abs(m1-m2)/sqrt(s1^2/n1 + s2^2/n2)
2*pt(t, n1 + n2 -2, lower.tail=F)
}

>homebrew_two_tailed_t_test(3.5, 3, 50, 40, 2, 1.9)
0.2288375

• Thank you, but what about p-value? Commented Jul 28, 2013 at 13:27
• Reference my edited post Commented Jul 28, 2013 at 13:33
• Sorry, I still do not see how to compute p-value. Tables for Student test are not p-values. Commented Jul 28, 2013 at 13:38
• Assuming David Marx calculated the $t$-value and the $df$ correctly, R gives a p-value of: pt(1.69, 88, lower.tail = FALSE) = 0.04728384. Note that this is a one-sided test, so you need to multiply it by two for the two sided test which is (non-significant): 0.0946. Commented Jul 28, 2013 at 14:29
• FYI there was a slight miscalculation earlier in the t figure I gave: i had treated the standard deviations you provided as though they were variances. I updated my answer to give you the correct t and corresponding p values, and have also provided a small r snippet for you. Commented Jul 28, 2013 at 14:40