Sample t-test questions and walk-throughs
Example 1: A t-test for the difference between a sample mean and an hypothesized population
mean
Research Question: Does the average bear sleep 8 hours per night?
Data: Your data – a record of how many hours in a randomly selected night each of 40 randomly
selected bears slept. From this you are able to calculate the following:
Sample mean () = 8.2 hours
Sample variance ( ) = 1.8 hours2
Sample size (N) = 40
1. State your research question in terms of a testable null-hypothesis and alternative
hypothesis.
Null Hypothesis (H0): : , = 8 ℎ
Alternative Hypothesis (H1): : , ≠ 8 ℎ
2. State the critical value for your test (if your p-value is less than this number, you will reject
your null-hypothesis). A common critical value is 0.05, but you can be more demanding of
what you’ll consider evidence by setting a smaller value, such as 0.01 or even 0.001.
Critical value (α) = 0.05
3. Use your sample variance to find your sample standard deviation by taking the square root.
Sample SD ( ) = √1.8 ℎ = 1.34 hours
4. Use the sample SD to find the standard error of the mean by dividing it by the square root
of N
Standard Error (()) =
.
=
√ √
= 0.212
5. Find your t-statistic by differencing your sample mean from your hypothesized population
mean and dividing by the standard error.
!",# &.!&
t-stat = = = = 0.943
$%() .
6. Find your degrees of freedom (n -1, in this case)
+ − 1 = 40 − 1 = -.
7. Find your p-value by finding the area to the extreme of your t-stat under a t-distribution
with the appropriate degrees of freedom. And – because this is a two-tailed test – double it.
(If it were a one tailed test, you wouldn’t double it)
p-value = p = 0.351486
To find this p-value enter the following code into Excel: =2*T.DIST(-abs(t-stat), df, 1). So in this
example, you’d use =2*T.DIST(-abs(0.943), 39, 1).
If this were a one-tailed test, you would do the same thing, just without the “2*” in front.
8. Reject your null-hypothesis if your p-value is below your critical value. Otherwise, fail to
reject your null-hypothesis.
0.351486 > 0.05, so fail to reject the null-hypothesis.
9. Use words to describe the outcome of your analysis
A t-test was performed to test the null-hypothesis that the average bear sleeps 8 hours each night. An
examination of 40 bears’ sleep found an average sleep duration of 8.2 hours with a standard deviation of
1.34 hours. A t-test of the hypothesis that bears sleep 8.0 hours yielded a p-value of 0.351486, indicating
that, if bears do indeed sleep 8 hours per night on average, there is a 35.15% chance of sampling a group
of 40 bears with an average sleep time at least as different from 8 hours as what we observed. This is a
significantly high probability to cause us to fail-to-reject our null hypothesis with 95% confidence. As
such, we cannot reject the hypothesis that bears as a population sleep, on average, 8 hours per night.
Example 2: A t-test for a difference in two sample means (against the hypothesis that there is no
difference)
Research Question: Does the average college freshman eat the same number of calories/day as the
average college senior?
Data: Your data – the number of calories consumed on a random day by 80 randomly selected college
freshman and 100 randomly selected college seniors. From this you are able to calculate the following:
Sample mean for Freshmen (/ ) = 2,120 calories
Sample mean for Seniors (̅) = 2,076 calories
Sample variance for Freshmen (1 ) = 16,400 calories2
Sample variance for Seniors ($ ) = 20,200 calories2
Freshmen sampled (21 ) = 80
Seniors sampled (2$ ) = 100
1. State your research question in terms of a testable null-hypothesis and alternative
hypothesis.
Null Hypothesis (H0): : 1 = $
(Note: this implies a null-hypothesis that 1 − $ = 0)
Alternative Hypothesis (H1): : 1 ≠ $
2. State your critical value
Critical value (α) = 0.05
3. Use your sample means to find the difference in the means between your two samples.
Difference in means = / − ̅ = 44
4. Use your sample variances and sample sizes to find the standard error of the difference.
1 16,400 20,200
(/ − ̅) = 3 + $ = 3 + = 20.17 89:;<
+1 +$ 80 100
5. Find your t-statistic by differencing your sample mean difference from your hypothesized
population mean difference, and then dividing by the standard error.
(1 !$̅)!("= !"> ) !
t-stat = = $%(1 !$̅)
= .? = 2.18
6. Find your degrees of freedom (@A + @B − C, in this case)
+1 + +$ − 2 = 80 + 100 − 2 = 178
7. Find your p-value by finding the area to the extreme of your t-stat under the t-distribution
with the appropriate degrees of freedom. And – because this is a two-tailed test – double it.
(If it were a one tailed test, you wouldn’t double it)
p-value = p = 0.03057
Again, to find this use =2*T.DIST(-abs(t-stat), df, 1), which in this case means =2*T.DIST(-2.18, 178, 1)
8. Reject your null-hypothesis if your p-value is below your critical value. Otherwise, fail to
reject your null-hypothesis.
0.03057 < 0.05, so reject the null-hypothesis at the 95% level of confidence.
9. Use words to describe the outcome of your analysis
A t-test was performed to test the null-hypothesis that the average college freshman consumes the same
number of calories/day as the average college senior. This test yielded a p-value of 0.030563, indicating
that, if freshmen and seniors do consume the same number of calories/day, there is only a 3.06% chance
of observing two samples (one of freshmen, one of seniors) that have a difference in calories/day
consumption as large or larger than the two groups that we sampled. This is a sufficiently small
probability to lead us to reject our null-hypothesis with 95% confidence, and therefore conclude that there
is a statistically significant difference in the calorie/day consumption of college freshmen and college
seniors.
Example 3: Construct a 95% confidence interval around an estimated difference in means
Continuing with the numbers from Example 2, we might want to estimate the 95% confidence interval
surrounding our observed difference in mean calories consumed between these two groups. To do so,
we…
First: look to Steps 3 and 4 to find our observed difference in means (44 calories/day) and the
standard error of this difference (20.17 calories).
Second: Find the appropriate critical values for our 95% confidence interval given our degrees of
freedom.
We can find this value in Excel using =T.INV(0.025, df). Here, we’d use =T.INV(0.025, 178), which
gives us the value -1.97338.
The “0.025” in that formula comes from the fact that this is a 2-tailed test and we want to find the 95%
confidence interval. The 95% confidence interval leaves 5% area “on the outside,” which means 2.5%
(0.025) in each tail.
NOTE: The larger your degrees of freedom (sample size) the closer your critical value will be to -1.96.
Third: Calculate the confidence interval for the difference using this formula:
95% confidence interval = DE<F<G H;II<<+8< ± K; ;89: L9:< ∗ (H;II<<+8<)
In this case, that works out to:
95% confidence interval = 44 89:;< ± −1.97388 ∗ 20.17
Doing that adding and subtracting (±) we can write this as:
{4.197 89:;< , 83.803 89:;<}
In other words, we can say with 95% confidence that the true difference in calories consumed is between
4.197 and 83.803 per day.
We will fail to reject with 95% confidence any null-hypothesis in this range.
We will reject with 95% confidence any null-hypothesis outside this range.
For example, the null-hypothesis from example 2 of a 0 calorie difference will be rejected, because 0 is
not inside the interval from 4.197 to 83.803.