Login
📚 Answering Questions with Data
Chapters ▾

6.2 One-sample t-test: A new t-test

Now we are ready to talk about t-test. We will talk about three of them. We start with the one-sample t-test.

Commonly, the one-sample t-test is used to estimate the chances that your sample came from a particular population. Specifically, you might want to know whether the mean that you found from your sample, could have come from a particular population having a particular mean.

Straight away, the one-sample t-test becomes a little confusing (and I haven’t even described it yet). Officially, it uses known parameters from the population, like the mean of the population and the standard deviation of the population. However, most times you don’t know those parameters of the population! So, you have to estimate them from your sample. Remember from the chapters on descriptive statistics and sampling, our sample mean is an unbiased estimate of the population mean. And, our sample standard deviation (the one where we divide by n-1) is an unbiased estimate of the population standard deviation. When Gosset developed the t-test, he recognized that he could use these estimates from his samples, to make the t-test. Here is the formula for the one sample t-test, we first use words, and then become more specific:

6.2.1 Formulas for one-sample t-test

name of statistic = measure of effect measure of error

t = measure of effect measure of error

t = Mean difference standard error

t = X ¯ u S X ¯

t = Sample Mean  - Population Mean Sample Standard Error

Estimated Standard Error = Standard Error of Sample = s N

Where, s is the sample standard deviation.

Some of you may have gone cross-eyed looking at all of this. Remember, we’ve seen it before when we divided our mean by the standard deviation in the first bit. The t-test is just a measure of a sample mean, divided by the standard error of the sample mean. That is it.

6.2.2 What does t represent?

t gives us a measure of confidence, just like our previous ratio for dividing the mean by a standard deviations. The only difference with t, is that we divide by the standard error of mean (remember, this is also a standard deviation, it is the standard deviation of the sampling distribution of the mean)

t is a property of the data that you collect. You compute it with a sample mean, and a sample standard error (there’s one more thing in the one-sample formula, the population mean, which we get to in a moment). This is why we call t, a sample-statistic. It’s a statistic we compute from the sample.

What kinds of numbers should we expect to find for these ts? How could we figure that out?

Let’s start small and work through some examples. Imagine your sample mean is 5. You want to know if it came from a population that also has a mean of 5. In this case, what would t be? It would be zero: we first subtract the sample mean from the population mean, 55=0. Because the numerator is 0, t will be zero. So, t = 0, occurs, when there is no difference.

Let’s say you take another sample, do you think the mean will be 5 every time, probably not. Let’s say the mean is 6. So, what can t be here? It will be a positive number, because 6-5= +1. But, will t be +1? That depends on the standard error of the sample. If the standard error of the sample is 1, then t could be 1, because 1/1 = 1.

If the sample standard error is smaller than 1, what happens to t? It gets bigger right? For example, 1 divided by 0.5 = 2. If the sample standard error was 0.5, t would be 2. And, what could we do with this information? Well, it be like a measure of confidence. As t gets bigger we could be more confident in the mean difference we are measuring.

Can t be smaller than 1? Sure, it can. If the sample standard error is big, say like 2, then t will be smaller than one (in our case), e.g., 1/2 =.5. The direction of the difference between the sample mean and population mean, can also make the t become negative. What if our sample mean was 4. Well, then t will be negative, because the mean difference in the numerator will be negative, and the number in the bottom (denominator) will always be positive (remember why, it’s the standard error, computed from the sample standard deviation, which is always positive because of the squaring that we did.).

So, that is some intuitions about what the kinds of values t can take. t can be positive or negative, and big or small.

Let’s do one more thing to build our intuitions about what t can look like. How about we sample some numbers and then measure the sample mean and the standard error of the mean, and then plot those two things against each each. This will show us how a sample mean typically varies with respect to the standard error of the mean.

In Figure 6.1, I pulled 1,000 samples of N=10 from a normal distribution (mean = 0, sd = 1). Each time I measured the mean and standard error of the sample. That gave two descriptive statistics for each sample, letting us plot each sample as dot in a scatter plot.

Scatter plot of 1,000 simulated samples, plotting each sample's mean (x-axis, about -1 to 1) against its standard error (y-axis, about 0.1 to 0.55). The open circles form a shapeless cloud with no trend, showing that a sample's mean and its standard error vary independently.
Figure 6.1: A scatter plot with sample mean on the x-axis, and standard error of the mean on the y-axis

What we get is a cloud of dots. You might notice the cloud has a circular quality. There’s more dots in the middle, and fewer dots as they radiate out from the middle. The dot cloud shows us the general range of the sample mean, for example most of the dots are in between -1 and 1. Similarly, the range for the sample standard error is roughly between.2 and.5. Remember, each dot represents one sample.

We can look at the same data a different way. For example, rather than using a scatter plot, we can divide the mean for each dot by the standard error for each dot. Figure 6.2 shows the result in a histogram.

Histogram of 1,000 sample means each divided by its own standard error. The resulting ratios form a bell-shaped distribution centered on zero, mostly between -3 and 3, with a few extreme values trailing out toward -8.
Figure 6.2: A histogram of the sample means divided by the sample standard errors, this is a t-distribution.

Interesting, we can see the histogram is shaped like a normal curve. It is centered on 0, which is the most common value. As values become more extreme, they become less common. If you remember, our formula for t, was the mean divided by the standard error of the mean. That’s what we did here. This histogram is showing you a t-distribution.

6.2.3 Calculating t from data

Let’s briefly calculate a t-value from a small sample. Let’s say we had 10 students do a true/false quiz with 5 questions on it. There’s a 50% chance of getting each answer correct.

Every student completes the 5 questions, we grade them, and then we find their performance (mean percent correct). What we want to know is whether the students were guessing. If they were all guessing, then the sample mean should be about 50%, it shouldn’t be different from chance, which is 50%. Let’s look at Table 6.1.

Table 6.1: Calculating the t-value for a one-sample test.
studentsscoresmeanDifference_from_MeanSquared_Deviations
15061-11121
27061981
36061-11
44061-21441
5806119361
63061-31961
7906129841
86061-11
97061981
106061-11
Sums61061002890
Means61610289
sd17.92
SEM5.67
t1.94003527336861

You can see the scores column has all of the test scores for each of the 10 students. We did the things we need to do to compute the standard deviation.

Remember the sample standard deviation is the square root of the sample variance, or:

sample standard deviation = i n ( x i x ¯ ) 2 N 1

sd = 2890 10 1 = 17.92

The standard error of the mean, is the standard deviation divided by the square root of N

SEM = s N = 17.92 10 = 5.67

t is the difference between our sample mean (61), and our population mean (50, assuming chance), divided by the standard error of the mean.

t = X ¯ u S X ¯ = X ¯ u S E M = 61 50 5.67 = 1.94

And, that is you how calculate t, by hand. It’s a pain. I was annoyed doing it this way. In the lab, you learn how to calculate t using software, so it will just spit out t. For example in R, all you have to do is this:

t.test(scores, mu=50)
Show expected output

 One Sample t-test

data:  scores
t = 1.9412, df = 9, p-value = 0.08415
alternative hypothesis: true mean is not equal to 50
95 percent confidence interval:
 48.18111 73.81889
sample estimates:
mean of x 
       61

6.2.4 How does t behave?

If t is just a number that we can compute from our sample (it is), what can we do with it? How can we use t for statistical inference?

Remember back to the chapter on sampling and distributions, that’s where we discussed the sampling distribution of the sample mean. Remember, we made a lot of samples, then computed the mean for each sample, then we plotted a histogram of the sample means. Later, in that same section, we mentioned that we could generate sampling distributions for any statistic. For each sample, we could compute the mean, the standard deviation, the standard error, and now even t, if we wanted to. We could generate 10,000 samples, and draw four histograms, one for each sampling distribution for each statistic.

This is exactly what I did, and the results are shown in the four panels of Figure 6.3 below. I used a sample size of 20, and drew random observations for each sample from a normal distribution, with mean = 0, and standard deviation = 1. Let’s look at the sampling distributions for each of the statistics. t was computed assuming with the population mean assumed to be 0.

Four histograms from 10,000 simulated samples of size 20: sample means centered on 0, sample standard deviations centered near 1, standard errors of the mean centered near 0.22, and t-values centered on 0. All four sampling distributions are roughly bell-shaped.
Figure 6.3: Sampling distributions for the mean, standard deviation, standard error of the mean, and t.

We see four sampling distributions. This is how statistical summaries of these summaries behave. We have used the word chance windows before. These are four chance windows, measuring different aspects of the sample. In this case, all of the samples came from the same normal distribution. Because of sampling error, each sample is not identical. The means are not identical, the standard deviations are not identical, sample standard error of the means are not identical, and the ts of the samples are not identical. They all have some variation, as shown by the histograms. This is how samples of size 20 behave.

We can see straight away, that in this case, we are unlikely to get a sample mean of 2. That’s way outside the window. The range for the sampling distribution of the mean is around -.5 to +.5, and is centered on 0 (the population mean, would you believe!).

We are unlikely to get sample standard deviations of between.6 and 1.5, that is a different range, specific to the sample standard deviation.

Same thing with the sample standard error of the mean, the range here is even smaller, mostly between.1, and.3. You would rarely find a sample with a standard error of the mean greater than.3. Virtually never would you find one of say 1 (for this situation).

Now, look at t. It’s range is basically between -3 and +3 here. 3s barely happen at all. You pretty much never see a 5 or -5 in this situation.

All of these sampling windows are chance windows, and they can all be used in the same way as we have used similar sampling distributions before (e.g., Crump Test, and Randomization Test) for statistical inference. For all of them we would follow the same process:

  1. Generate these distributions
  2. Look at your sample statistics for the data you have (mean, SD, SEM, and t)
  3. Find the likelihood of obtaining that value or greater
  4. Obtain that probability
  5. See if you think your sample statistics were probable or improbable.

We’ll formalize this in a second. I just want you to know that what you will be doing is something that you have already done before. For example, in the Crump test and the Randomization test we focused on the distribution of mean differences. We could do that again here, but instead, we will focus on the distribution of t values. We then apply the same kinds of decision rules to the t distribution, as we did for the other distributions. Below you will see a graph you have already seen, except this time it is a distribution of ts, not mean differences:

Remember, if we obtained a single t from one sample we collected, we could consult the chance window in Figure 6.4 below to find out whether the t we obtained from the sample was likely or unlikely to occur by chance.

Histogram of simulated t-values centered on zero, overlaid with colored decision regions: a red central band labeled CHANCE between about -2 and 2, gray bands marked with question marks reaching out to the most extreme simulated values near -6 and 6, and green regions beyond them labeled NOT CHANCE.
Figure 6.4: Applying decision criteria to the t-distribution. Histogram of ts from samples (n=20) drawn from the same normal distribution (u=0, sd=1)

6.2.5 Making a decision

From our early example involving the TRUE/FALSE quizzes, we are now ready to make some kind of decision about what happened there. We found a mean difference of 11. We found a t = 1.9411765. The probability of this t or larger occurring is p = 0.0841503. We were testing the idea that our sample mean of 61 could have come from a normal distribution with mean = 50. The t test tells us that the t for our sample, or a larger one, would happen with p = 0.0841503. In other words, chance can do it a kind of small amount of time, but not often. In English, this means that all of the students could have been guessing, but it wasn’t that likely that were just guessing.

The next t-test is called a paired samples t-test. And, spoiler alert, we will find out that a paired samples t-test is actually a one-sample t-test in disguise (WHAT!), yes it is. If the one-sample t-test didn’t make sense to you, read the next section.

Adapted from Answering Questions with Data: Introductory Statistics for Psychology Students, by Matthew J. C. Crump (Brooklyn College of CUNY), crumplab.com/statistics, licensed under CC BY-SA 4.0. Portions adapt Danielle Navarro's Learning Statistics with R (CC BY-SA). Changes were made; this adaptation is distributed under the same license. License: CC-BY-SA-4.0.