Men
Women
You can clearly see some overlap in the body fat measurements for the men and women in our sample, but also some differences. Just by looking at the data, it's hard to draw any solid conclusions about whether the underlying populations of men and women at the gym have the same mean body fat. That is the value of statistical tests – they provide a common, statistically valid way to make decisions, so that everyone makes the same decision on the same set of data values.
Let’s start by answering: Is the two-sample t -test an appropriate method to evaluate the difference in body fat between men and women?
Before jumping into analysis, we should always take a quick look at the data. The figure below shows histograms and summary statistics for the men and women.
The two histograms are on the same scale. From a quick look, we can see that there are no very unusual points, or outliers . The data look roughly bell-shaped, so our initial idea of a normal distribution seems reasonable.
Examining the summary statistics, we see that the standard deviations are similar. This supports the idea of equal variances. We can also check this using a test for variances.
Based on these observations, the two-sample t -test appears to be an appropriate method to test for a difference in means.
For each group, we need the average, standard deviation and sample size. These are shown in the table below.
Women | 10 | 22.29 | 5.32 |
Men | 13 | 14.95 | 6.84 |
Without doing any testing, we can see that the averages for men and women in our samples are not the same. But how different are they? Are the averages “close enough” for us to conclude that mean body fat is the same for the larger population of men and women at the gym? Or are the averages too different for us to make this conclusion?
We'll further explain the principles underlying the two sample t -test in the statistical details section below, but let's first proceed through the steps from beginning to end. We start by calculating our test statistic. This calculation begins with finding the difference between the two averages:
$ 22.29 - 14.95 = 7.34 $
This difference in our samples estimates the difference between the population means for the two groups.
Next, we calculate the pooled standard deviation. This builds a combined estimate of the overall standard deviation. The estimate adjusts for different group sizes. First, we calculate the pooled variance:
$ s_p^2 = \frac{((n_1 - 1)s_1^2) + ((n_2 - 1)s_2^2)} {n_1 + n_2 - 2} $
$ s_p^2 = \frac{((10 - 1)5.32^2) + ((13 - 1)6.84^2)}{(10 + 13 - 2)} $
$ = \frac{(9\times28.30) + (12\times46.82)}{21} $
$ = \frac{(254.7 + 561.85)}{21} $
$ =\frac{816.55}{21} = 38.88 $
Next, we take the square root of the pooled variance to get the pooled standard deviation. This is:
$ \sqrt{38.88} = 6.24 $
We now have all the pieces for our test statistic. We have the difference of the averages, the pooled standard deviation and the sample sizes. We calculate our test statistic as follows:
$ t = \frac{\text{difference of group averages}}{\text{standard error of difference}} = \frac{7.34}{(6.24\times \sqrt{(1/10 + 1/13)})} = \frac{7.34}{2.62} = 2.80 $
To evaluate the difference between the means in order to make a decision about our gym programs, we compare the test statistic to a theoretical value from the t- distribution. This activity involves four steps:
Let’s look at the body fat data and the two-sample t -test using statistical terms.
Our null hypothesis is that the underlying population means are the same. The null hypothesis is written as:
$ H_o: \mathrm{\mu_1} =\mathrm{\mu_2} $
The alternative hypothesis is that the means are not equal. This is written as:
$ H_o: \mathrm{\mu_1} \neq \mathrm{\mu_2} $
We calculate the average for each group, and then calculate the difference between the two averages. This is written as:
$\overline{x_1} - \overline{x_2} $
We calculate the pooled standard deviation. This assumes that the underlying population variances are equal. The pooled variance formula is written as:
The formula shows the sample size for the first group as n 1 and the second group as n 2 . The standard deviations for the two groups are s 1 and s 2 . This estimate allows the two groups to have different numbers of observations. The pooled standard deviation is the square root of the variance and is written as s p .
What if your sample sizes for the two groups are the same? In this situation, the pooled estimate of variance is simply the average of the variances for the two groups:
$ s_p^2 = \frac{(s_1^2 + s_2^2)}{2} $
The test statistic is calculated as:
$ t = \frac{(\overline{x_1} -\overline{x_2})}{s_p\sqrt{1/n_1 + 1/n_2}} $
The numerator of the test statistic is the difference between the two group averages. It estimates the difference between the two unknown population means. The denominator is an estimate of the standard error of the difference between the two unknown population means.
Technical Detail: For a single mean, the standard error is $ s/\sqrt{n} $ . The formula above extends this idea to two groups that use a pooled estimate for s (standard deviation), and that can have different group sizes.
We then compare the test statistic to a t value with our chosen alpha value and the degrees of freedom for our data. Using the body fat data as an example, we set α = 0.05. The degrees of freedom ( df ) are based on the group sizes and are calculated as:
$ df = n_1 + n_2 - 2 = 10 + 13 - 2 = 21 $
The formula shows the sample size for the first group as n 1 and the second group as n 2 . Statisticians write the t value with α = 0.05 and 21 degrees of freedom as:
$ t_{0.05,21} $
The t value with α = 0.05 and 21 degrees of freedom is 2.080. There are two possible results from our comparison:
When the variances for the two groups are not equal, we cannot use the pooled estimate of standard deviation. Instead, we take the standard error for each group separately. The test statistic is:
$ t = \frac{ (\overline{x_1} - \overline{x_2})}{\sqrt{s_1^2/n_1 + s_2^2/n_2}} $
The numerator of the test statistic is the same. It is the difference between the averages of the two groups. The denominator is an estimate of the overall standard error of the difference between means. It is based on the separate standard error for each group.
The degrees of freedom calculation for the t value is more complex with unequal variances than equal variances and is usually left up to statistical software packages. The key point to remember is that if you cannot use the pooled estimate of standard deviation, then you cannot use the simple formula for the degrees of freedom.
The normality assumption is more important when the two groups have small sample sizes than for larger sample sizes.
Normal distributions are symmetric, which means they are “even” on both sides of the center. Normal distributions do not have extreme values, or outliers. You can check these two features of a normal distribution with graphs. Earlier, we decided that the body fat data was “close enough” to normal to go ahead with the assumption of normality. The figure below shows a normal quantile plot for men and women, and supports our decision.
You can also perform a formal test for normality using software. The figure above shows results of testing for normality with JMP software. We test each group separately. Both the test for men and the test for women show that we cannot reject the hypothesis of a normal distribution. We can go ahead with the assumption that the body fat data for men and for women are normally distributed.
Testing for unequal variances is complex. We won’t show the calculations in detail, but will show the results from JMP software. The figure below shows results of a test for unequal variances for the body fat data.
Without diving into details of the different types of tests for unequal variances, we will use the F test. Before testing, we decide to accept a 10% risk of concluding the variances are equal when they are not. This means we have set α = 0.10.
Like most statistical software, JMP shows the p -value for a test. This is the likelihood of finding a more extreme value for the test statistic than the one observed. It’s difficult to calculate by hand. For the figure above, with the F test statistic of 1.654, the p- value is 0.4561. This is larger than our α value: 0.4561 > 0.10. We fail to reject the hypothesis of equal variances. In practical terms, we can go ahead with the two-sample t -test with the assumption of equal variances for the two groups.
Using a visual, you can check to see if your test statistic is a more extreme value in the distribution. The figure below shows a t- distribution with 21 degrees of freedom.
Since our test is two-sided and we have set α = .05, the figure shows that the value of 2.080 “cuts off” 2.5% of the data in each of the two tails. Only 5% of the data overall is further out in the tails than 2.080. Because our test statistic of 2.80 is beyond the cut-off point, we reject the null hypothesis of equal means.
The figure below shows results for the two-sample t -test for the body fat data from JMP software.
The results for the two-sample t -test that assumes equal variances are the same as our calculations earlier. The test statistic is 2.79996. The software shows results for a two-sided test and for one-sided tests. The two-sided test is what we want (Prob > |t|). Our null hypothesis is that the mean body fat for men and women is equal. Our alternative hypothesis is that the mean body fat is not equal. The one-sided tests are for one-sided alternative hypotheses – for example, for a null hypothesis that mean body fat for men is less than that for women.
We can reject the hypothesis of equal mean body fat for the two groups and conclude that we have evidence body fat differs in the population between men and women. The software shows a p -value of 0.0107. We decided on a 5% risk of concluding the mean body fat for men and women are different, when they are not. It is important to make this decision before doing the statistical test.
The figure also shows the results for the t- test that does not assume equal variances. This test does not use the pooled estimate of the standard deviation. As was mentioned above, this test also has a complex formula for degrees of freedom. You can see that the degrees of freedom are 20.9888. The software shows a p- value of 0.0086. Again, with our decision of a 5% risk, we can reject the null hypothesis of equal mean body fat for men and women.
If you have more than two independent groups, you cannot use the two-sample t- test. You should use a multiple comparison method. ANOVA, or analysis of variance, is one such method. Other multiple comparison methods include the Tukey-Kramer test of all pairwise differences, analysis of means (ANOM) to compare group means to the overall mean or Dunnett’s test to compare each group mean to a control mean.
If your sample size is very small, it might be hard to test for normality. In this situation, you might need to use your understanding of the measurements. For example, for the body fat data, the trainer knows that the underlying distribution of body fat is normally distributed. Even for a very small sample, the trainer would likely go ahead with the t -test and assume normality.
What if you know the underlying measurements are not normally distributed? Or what if your sample size is large and the test for normality is rejected? In this situation, you can use nonparametric analyses. These types of analyses do not depend on an assumption that the data values are from a specific distribution. For the two-sample t -test, the Wilcoxon rank sum test is a nonparametric test that could be used.
Run a free plagiarism check in 10 minutes, generate accurate citations for free.
Published on January 31, 2020 by Rebecca Bevans . Revised on June 22, 2023.
A t test is a statistical test that is used to compare the means of two groups. It is often used in hypothesis testing to determine whether a process or treatment actually has an effect on the population of interest, or whether two groups are different from one another.
When to use a t test, what type of t test should i use, performing a t test, interpreting test results, presenting the results of a t test, other interesting articles, frequently asked questions about t tests.
A t test can only be used when comparing the means of two groups (a.k.a. pairwise comparison). If you want to compare more than two groups, or if you want to do multiple pairwise comparisons, use an ANOVA test or a post-hoc test.
The t test is a parametric test of difference, meaning that it makes the same assumptions about your data as other parametric tests. The t test assumes your data:
If your data do not fit these assumptions, you can try a nonparametric alternative to the t test, such as the Wilcoxon Signed-Rank test for data with unequal variances .
When choosing a t test, you will need to consider two things: whether the groups being compared come from a single population or two different populations, and whether you want to test the difference in a specific direction.
The t test estimates the true difference between two group means using the ratio of the difference in group means over the pooled standard error of both groups. You can calculate it manually using a formula, or use statistical analysis software.
The formula for the two-sample t test (a.k.a. the Student’s t-test) is shown below.
In this formula, t is the t value, x 1 and x 2 are the means of the two groups being compared, s 2 is the pooled standard error of the two groups, and n 1 and n 2 are the number of observations in each of the groups.
A larger t value shows that the difference between group means is greater than the pooled standard error, indicating a more significant difference between the groups.
You can compare your calculated t value against the values in a critical value chart (e.g., Student’s t table) to determine whether your t value is greater than what would be expected by chance. If so, you can reject the null hypothesis and conclude that the two groups are in fact different.
Most statistical software (R, SPSS, etc.) includes a t test function. This built-in function will take your raw data and calculate the t value. It will then compare it to the critical value, and calculate a p -value . This way you can quickly see whether your groups are statistically different.
In your comparison of flower petal lengths, you decide to perform your t test using R. The code looks like this:
Download the data set to practice by yourself.
Sample data set
If you perform the t test for your flower hypothesis in R, you will receive the following output:
The output provides:
Discover proofreading & editing
When reporting your t test results, the most important values to include are the t value , the p value , and the degrees of freedom for the test. These will communicate to your audience whether the difference between the two groups is statistically significant (a.k.a. that it is unlikely to have happened by chance).
You can also include the summary statistics for the groups being compared, namely the mean and standard deviation . In R, the code for calculating the mean and the standard deviation from the data looks like this:
flower.data %>% group_by(Species) %>% summarize(mean_length = mean(Petal.Length), sd_length = sd(Petal.Length))
In our example, you would report the results like this:
If you want to know more about statistics , methodology , or research bias , make sure to check out some of our other articles with explanations and examples.
Methodology
Research bias
A t-test is a statistical test that compares the means of two samples . It is used in hypothesis testing , with a null hypothesis that the difference in group means is zero and an alternate hypothesis that the difference in group means is different from zero.
A t-test measures the difference in group means divided by the pooled standard error of the two group means.
In this way, it calculates a number (the t-value) illustrating the magnitude of the difference between the two group means being compared, and estimates the likelihood that this difference exists purely by chance (p-value).
Your choice of t-test depends on whether you are studying one group or two groups, and whether you care about the direction of the difference in group means.
If you are studying one group, use a paired t-test to compare the group mean over time or after an intervention, or use a one-sample t-test to compare the group mean to a standard value. If you are studying two groups, use a two-sample t-test .
If you want to know only whether a difference exists, use a two-tailed test . If you want to know if one group mean is greater or less than the other, use a left-tailed or right-tailed one-tailed test .
A one-sample t-test is used to compare a single population to a standard value (for example, to determine whether the average lifespan of a specific town is different from the country average).
A paired t-test is used to compare a single population before and after some experimental intervention or at two different points in time (for example, measuring student performance on a test before and after being taught the material).
A t-test should not be used to measure differences among more than two groups, because the error structure for a t-test will underestimate the actual error when many groups are being compared.
If you want to compare the means of several groups at once, it’s best to use another statistical test such as ANOVA or a post-hoc test.
If you want to cite this source, you can copy and paste the citation or click the “Cite this Scribbr article” button to automatically add the citation to our free Citation Generator.
Bevans, R. (2023, June 22). An Introduction to t Tests | Definitions, Formula and Examples. Scribbr. Retrieved July 23, 2024, from https://www.scribbr.com/statistics/t-test/
Other students also liked, choosing the right statistical test | types & examples, hypothesis testing | a step-by-step guide with easy examples, test statistics | definition, interpretation, and examples, what is your plagiarism score.
Statistics By Jim
Making statistics intuitive
By Jim Frost 3 Comments
Use an independent samples t test when you want to compare the means of precisely two groups—no more and no less! Typically, you perform this test to determine whether two population means are different. This procedure is an inferential statistical hypothesis test, meaning it uses samples to draw conclusions about populations. The independent samples t test is also known as the two sample t test.
For an example of an independent t test, do students who learn using Method A have a different mean score than those who learn using Method B?
In this post, you’ll learn about the hypotheses, assumptions, and how to interpret the results for independent samples t tests.
Related post : Difference between Descriptive and Inferential Statistics
Independent samples t tests have the following hypotheses:
If the p-value is less than your significance level (e.g., 0.05), you can reject the null hypothesis. The difference between the two means is statistically significant. Your sample provides strong enough evidence to conclude that the two population means are not equal.
Notice how the hypotheses for the two sample t test relate to independent populations. They do not contain the same subjects.
Learn how this analysis compares to the Z Test .
Related posts : How to Interpret P Values and Null Hypothesis: Definition, Rejecting & Examples .
For reliable independent samples t test results, your data should satisfy the following assumptions:
Drawing a random sample from the population you are studying helps ensure that your data represent the population. Representative samples are vital when you want to make inferences about the population. If your data do not represent the population, your analysis results will not be valid for that population.
You must draw a random sample from your population of interest. Each item or person in the population must have an equal probability of being selected.
Related posts : Populations, Parameters, and Samples in Inferential Statistics and Representative Samples: Definition, Uses & Examples .
T tests require continuous data . Continuous variables can take on any numeric value, and the scale can be meaningfully divided into smaller increments, including fractional and decimal values. There are an infinite number of possible values between any two values. Typically, you measure continuous variables on a scale. For example, when you measure temperature, weight, and height, you have continuous data.
Other hypothesis tests can handle different types of data. For more information, read Comparing Hypothesis Tests for Continuous, Binary, and Count Data .
All t-tests assume that your data follow the normal distribution . However, your group distributions can be skewed if your sample size is large enough thanks to the central limit theorem.
For the independent samples t test, when each group is larger than 15, your data can be mildly skewed and the test results will still be valid. However, if your sample size is less than 15 per group, graph your data and determine whether the two distributions are skewed. In this case, you might need to use a nonparametric test . The Mann Whitney U test is the nonparametric test that corresponds to the independent samples t-test.
Fortunately, if you have more than 15 observations in each group for a two sample t test, you don’t have to worry about the normality assumption too much.
Be sure to check for outliers because they can throw off the results.
Related post : Central Limit Theorem and Skewed Distributions
Independent samples contain different sets of items in each sample. Independent samples t tests compare two distinct samples. Hence, it’s a two sample t test. If you have the same people or items in both groups, you can use the paired t-test .
Related post : Independent and Dependent Samples
Variance, and the closely related standard deviation, are measures of variability. Because the two sample t test uses two independent samples, each sample has its own variance. Consequently, the independent samples t test has two methods. One method assumes that the two groups have equal variances while the other does not assume they are equal. The form that does not assume equal variances is known as Welch’s t-test.
When the sample sizes for both groups are roughly equal, and you have a moderate sample size, t-tests are robust to unequal variances. If one group has twice the standard deviation of another group, it’s time to use Welch’s t-test! However, you don’t need to worry about smaller differences.
If you have unequal variances and unequal sample sizes, it’s vital to use the unequal variances version of the two sample t test!
Related post : Standard Deviations
Let’s run an example independent sample t test! Our hypothetical scenario is that we are comparing scores from two teaching methods. We drew two random samples of students. Students in one group learned using Method A while the other group used Method B. These samples contain entirely separate students.
Now, we want to determine whether the two means are different. Download the CSV file that contains the independent samples t test example data: t-TestExamples .
Here is what the data look like in the datasheet.
Let’s assume that the variances are equal and use the Assuming Equal Variances version.
Here’s how to read and report the results for an independent samples t test.
The output indicates that the mean for Method A is 71.50 and for Method B it is 84.74. Looking in the Standard Deviation column, we can see that they are not exactly equal, but they are close enough to assume equal variances.
Because the p-value (0.000) for our independent samples t test is less than the standard significance level of 0.05, we can reject the null hypothesis. If the p-value is low, the null must go! Our sample data support the claim that the population means are different. Specifically, Method B’s mean is greater than Method A’s mean. If high scores are better, then Method B is significantly better than Method A.
Learn more about Statistical Significance: Definition & Meaning .
The two sample t test estimates that the mean difference is -13.24. However, that estimate is based on 30 observations split between the two groups and it is unlikely to equal the population difference. The confidence interval indicates that the mean difference between these two methods for the entire population is likely between -19.89 and -6.59. Learn more about confidence intervals .
The negative values reflect the fact that Method A has a lower mean than Method B (i.e., Method A – Method B < 0). Because the confidence interval excludes zero (no difference), we can conclude that the population means are different.
To learn more about performing t-tests and how they work, read the following posts:
June 15, 2022 at 12:30 am
Hi Jim. Just to say thank you. All I needed to learn was how to interpret “independent t test” results. and after reading this article, I am looking no further. Many thanks.
December 1, 2021 at 11:08 am
Lily, I don’t know if Jim will reply as he posted this in Oct. I am just now reading it too. From my work in education, I would look at combining the three tests (average score or total points) so that each student in each group has one test.
November 28, 2021 at 8:23 am
Hi, thanks for your articles about statistics and I would like to ask you some questions. How many test variables can a T-test analyse? I’ve selected 2 groups of students to test two different teaching methods and collected the results from three exams (Is it means I have 3 dependent variables?) Then I used an independent sample T-test to analyse the data. My research purpose is to find out which teaching method is more effective. Did I use the wrong statistical method? Look forward to your reply.
Introduction.
The independent t-test, also called the two sample t-test, independent-samples t-test or student's t-test, is an inferential statistical test that determines whether there is a statistically significant difference between the means in two unrelated groups.
The null hypothesis for the independent t-test is that the population means from the two unrelated groups are equal:
H 0 : u 1 = u 2
In most cases, we are looking to see if we can show that we can reject the null hypothesis and accept the alternative hypothesis, which is that the population means are not equal:
H A : u 1 ≠ u 2
To do this, we need to set a significance level (also called alpha) that allows us to either reject or accept the alternative hypothesis. Most commonly, this value is set at 0.05.
In order to run an independent t-test, you need the following:
Unrelated groups, also called unpaired groups or independent groups, are groups in which the cases (e.g., participants) in each group are different. Often we are investigating differences in individuals, which means that when comparing two groups, an individual in one group cannot also be a member of the other group and vice versa. An example would be gender - an individual would have to be classified as either male or female – not both.
The independent t-test requires that the dependent variable is approximately normally distributed within each group.
Note: Technically, it is the residuals that need to be normally distributed, but for an independent t-test, both will give you the same result.
You can test for this using a number of different tests, but the Shapiro-Wilks test of normality or a graphical method, such as a Q-Q Plot, are very common. You can run these tests using SPSS Statistics, the procedure for which can be found in our Testing for Normality guide. However, the t-test is described as a robust test with respect to the assumption of normality. This means that some deviation away from normality does not have a large influence on Type I error rates. The exception to this is if the ratio of the smallest to largest group size is greater than 1.5 (largest compared to smallest).
If you find that either one or both of your group's data is not approximately normally distributed and groups sizes differ greatly, you have two options: (1) transform your data so that the data becomes normally distributed (to do this in SPSS Statistics see our guide on Transforming Data ), or (2) run the Mann-Whitney U test which is a non-parametric test that does not require the assumption of normality (to run this test in SPSS Statistics see our guide on the Mann-Whitney U Test ).
The independent t-test assumes the variances of the two groups you are measuring are equal in the population. If your variances are unequal, this can affect the Type I error rate. The assumption of homogeneity of variance can be tested using Levene's Test of Equality of Variances, which is produced in SPSS Statistics when running the independent t-test procedure. If you have run Levene's Test of Equality of Variances in SPSS Statistics, you will get a result similar to that below:
This test for homogeneity of variance provides an F -statistic and a significance value ( p -value). We are primarily concerned with the significance value – if it is greater than 0.05 (i.e., p > .05), our group variances can be treated as equal. However, if p < 0.05, we have unequal variances and we have violated the assumption of homogeneity of variances.
If the Levene's Test for Equality of Variances is statistically significant, which indicates that the group variances are unequal in the population, you can correct for this violation by not using the pooled estimate for the error term for the t -statistic, but instead using an adjustment to the degrees of freedom using the Welch-Satterthwaite method. In all reality, you will probably never have heard of these adjustments because SPSS Statistics hides this information and simply labels the two options as "Equal variances assumed" and "Equal variances not assumed" without explicitly stating the underlying tests used. However, you can see the evidence of these tests as below:
From the result of Levene's Test for Equality of Variances, we can reject the null hypothesis that there is no difference in the variances between the groups and accept the alternative hypothesis that there is a statistically significant difference in the variances between groups. The effect of not being able to assume equal variances is evident in the final column of the above figure where we see a reduction in the value of the t -statistic and a large reduction in the degrees of freedom (df). This has the effect of increasing the p -value above the critical significance level of 0.05. In this case, we therefore do not accept the alternative hypothesis and accept that there are no statistically significant differences between means. This would not have been our conclusion had we not tested for homogeneity of variances.
When reporting the result of an independent t-test, you need to include the t -statistic value, the degrees of freedom (df) and the significance value of the test ( p -value). The format of the test result is: t (df) = t -statistic, p = significance value. Therefore, for the example above, you could report the result as t (7.001) = 2.233, p = 0.061.
In order to provide enough information for readers to fully understand the results when you have run an independent t-test, you should include the result of normality tests, Levene's Equality of Variances test, the two group means and standard deviations, the actual t-test result and the direction of the difference (if any). In addition, you might also wish to include the difference between the groups along with a 95% confidence interval. For example:
Inspection of Q-Q Plots revealed that cholesterol concentration was normally distributed for both groups and that there was homogeneity of variance as assessed by Levene's Test for Equality of Variances. Therefore, an independent t-test was run on the data with a 95% confidence interval (CI) for the mean difference. It was found that after the two interventions, cholesterol concentrations in the dietary group (6.15 ± 0.52 mmol/L) were significantly higher than the exercise group (5.80 ± 0.38 mmol/L) ( t (38) = 2.470, p = 0.018) with a difference of 0.35 (95% CI, 0.06 to 0.64) mmol/L.
To know how to run an independent t-test in SPSS Statistics, see our SPSS Statistics Independent-Samples T-Test guide. Alternatively, you can carry out an independent-samples t-test using Excel, R and RStudio .
Topics: Hypothesis Testing , Data Analysis
In statistics, t-tests are a type of hypothesis test that allows you to compare means. They are called t-tests because each t-test boils your sample data down to one number, the t-value. If you understand how t-tests calculate t-values, you’re well on your way to understanding how these tests work.
In this series of posts, I'm focusing on concepts rather than equations to show how t-tests work. However, this post includes two simple equations that I’ll work through using the analogy of a signal-to-noise ratio.
Minitab Statistical Software offers the 1-sample t-test, paired t-test, and the 2-sample t-test. Let's look at how each of these t-tests reduce your sample data down to the t-value.
Understanding this process is crucial to understanding how t-tests work. I'll show you the formula first, and then I’ll explain how it works.
Please notice that the formula is a ratio. A common analogy is that the t-value is the signal-to-noise ratio.
The numerator is the signal. You simply take the sample mean and subtract the null hypothesis value. If your sample mean is 10 and the null hypothesis is 6, the difference, or signal, is 4.
If there is no difference between the sample mean and null value, the signal in the numerator, as well as the value of the entire ratio, equals zero. For instance, if your sample mean is 6 and the null value is 6, the difference is zero.
As the difference between the sample mean and the null hypothesis mean increases in either the positive or negative direction, the strength of the signal increases.
The denominator is the noise. The equation in the denominator is a measure of variability known as the standard error of the mean . This statistic indicates how accurately your sample estimates the mean of the population. A larger number indicates that your sample estimate is less precise because it has more random error.
This random error is the “noise.” When there is more noise, you expect to see larger differences between the sample mean and the null hypothesis value even when the null hypothesis is true . We include the noise factor in the denominator because we must determine whether the signal is large enough to stand out from it.
Both the signal and noise values are in the units of your data. If your signal is 6 and the noise is 2, your t-value is 3. This t-value indicates that the difference is 3 times the size of the standard error. However, if there is a difference of the same size but your data have more variability (6), your t-value is only 1. The signal is at the same scale as the noise.
In this manner, t-values allow you to see how distinguishable your signal is from the noise. Relatively large signals and low levels of noise produce larger t-values. If the signal does not stand out from the noise, it’s likely that the observed difference between the sample estimate and the null hypothesis value is due to random error in the sample rather than a true difference at the population level.
Many people are confused about when to use a paired t-test and how it works. I’ll let you in on a little secret. The paired t-test and the 1-sample t-test are actually the same test in disguise! As we saw above, a 1-sample t-test compares one sample mean to a null hypothesis value. A paired t-test simply calculates the difference between paired observations (e.g., before and after) and then performs a 1-sample t-test on the differences.
You can test this with this data set to see how all of the results are identical, including the mean difference, t-value, p-value, and confidence interval of the difference.
Understanding that the paired t-test simply performs a 1-sample t-test on the paired differences can really help you understand how the paired t-test works and when to use it. You just need to figure out whether it makes sense to calculate the difference between each pair of observations.
For example, let’s assume that “before” and “after” represent test scores, and there was an intervention in between them. If the before and after scores in each row of the example worksheet represent the same subject, it makes sense to calculate the difference between the scores in this fashion—the paired t-test is appropriate. However, if the scores in each row are for different subjects, it doesn’t make sense to calculate the difference. In this case, you’d need to use another test, such as the 2-sample t-test, which I discuss below.
Using the paired t-test simply saves you the step of having to calculate the differences before performing the t-test. You just need to be sure that the paired differences make sense!
When it is appropriate to use a paired t-test, it can be more powerful than a 2-sample t-test. For more information, go to Overview for paired t .
The 2-sample t-test takes your sample data from two groups and boils it down to the t-value. The process is very similar to the 1-sample t-test, and you can still use the analogy of the signal-to-noise ratio. Unlike the paired t-test, the 2-sample t-test requires independent groups for each sample.
The formula is below, and then some discussion.
For the 2-sample t-test, the numerator is again the signal, which is the difference between the means of the two samples. For example, if the mean of group 1 is 10, and the mean of group 2 is 4, the difference is 6.
The default null hypothesis for a 2-sample t-test is that the two groups are equal. You can see in the equation that when the two groups are equal, the difference (and the entire ratio) also equals zero. As the difference between the two groups grows in either a positive or negative direction, the signal becomes stronger.
In a 2-sample t-test, the denominator is still the noise, but Minitab can use two different values. You can either assume that the variability in both groups is equal or not equal, and Minitab uses the corresponding estimate of the variability. Either way, the principle remains the same: you are comparing your signal to the noise to see how much the signal stands out.
Just like with the 1-sample t-test, for any given difference in the numerator, as you increase the noise value in the denominator, the t-value becomes smaller. To determine that the groups are different, you need a t-value that is large.
Each type of t-test uses a procedure to boil all of your sample data down to one value, the t-value. The calculations compare your sample mean(s) to the null hypothesis and incorporates both the sample size and the variability in the data. A t-value of 0 indicates that the sample results exactly equal the null hypothesis. In statistics, we call the difference between the sample estimate and the null hypothesis the effect size. As this difference increases, the absolute value of the t-value increases.
That’s all nice, but what does a t-value of, say, 2 really mean? From the discussion above, we know that a t-value of 2 indicates that the observed difference is twice the size of the variability in your data. However, we use t-tests to evaluate hypotheses rather than just figuring out the signal-to-noise ratio. We want to determine whether the effect size is statistically significant.
To see how we get from t-values to assessing hypotheses and determining statistical significance, read the other post in this series, Understanding t-Tests: t-values and t-distributions .
© 2023 Minitab, LLC. All Rights Reserved.
Table of contents
Welcome to our t-test calculator! Here you can not only easily perform one-sample t-tests , but also two-sample t-tests , as well as paired t-tests .
Do you prefer to find the p-value from t-test, or would you rather find the t-test critical values? Well, this t-test calculator can do both! 😊
What does a t-test tell you? Take a look at the text below, where we explain what actually gets tested when various types of t-tests are performed. Also, we explain when to use t-tests (in particular, whether to use the z-test vs. t-test) and what assumptions your data should satisfy for the results of a t-test to be valid. If you've ever wanted to know how to do a t-test by hand, we provide the necessary t-test formula, as well as tell you how to determine the number of degrees of freedom in a t-test.
A t-test is one of the most popular statistical tests for location , i.e., it deals with the population(s) mean value(s).
There are different types of t-tests that you can perform:
In the next section , we explain when to use which. Remember that a t-test can only be used for one or two groups . If you need to compare three (or more) means, use the analysis of variance ( ANOVA ) method.
The t-test is a parametric test, meaning that your data has to fulfill some assumptions :
If your sample doesn't fit these assumptions, you can resort to nonparametric alternatives. Visit our Mann–Whitney U test calculator or the Wilcoxon rank-sum test calculator to learn more. Other possibilities include the Wilcoxon signed-rank test or the sign test.
Your choice of t-test depends on whether you are studying one group or two groups:
One sample t-test
Choose the one-sample t-test to check if the mean of a population is equal to some pre-set hypothesized value .
The average volume of a drink sold in 0.33 l cans — is it really equal to 330 ml?
The average weight of people from a specific city — is it different from the national average?
Choose the two-sample t-test to check if the difference between the means of two populations is equal to some pre-determined value when the two samples have been chosen independently of each other.
In particular, you can use this test to check whether the two groups are different from one another .
The average difference in weight gain in two groups of people: one group was on a high-carb diet and the other on a high-fat diet.
The average difference in the results of a math test from students at two different universities.
This test is sometimes referred to as an independent samples t-test , or an unpaired samples t-test .
A paired t-test is used to investigate the change in the mean of a population before and after some experimental intervention , based on a paired sample, i.e., when each subject has been measured twice: before and after treatment.
In particular, you can use this test to check whether, on average, the treatment has had any effect on the population .
The change in student test performance before and after taking a course.
The change in blood pressure in patients before and after administering some drug.
So, you've decided which t-test to perform. These next steps will tell you how to calculate the p-value from t-test or its critical values, and then which decision to make about the null hypothesis.
Decide on the alternative hypothesis :
Use a two-tailed t-test if you only care whether the population's mean (or, in the case of two populations, the difference between the populations' means) agrees or disagrees with the pre-set value.
Use a one-tailed t-test if you want to test whether this mean (or difference in means) is greater/less than the pre-set value.
Compute your T-score value :
Formulas for the test statistic in t-tests include the sample size , as well as its mean and standard deviation . The exact formula depends on the t-test type — check the sections dedicated to each particular test for more details.
Determine the degrees of freedom for the t-test:
The degrees of freedom are the number of observations in a sample that are free to vary as we estimate statistical parameters. In the simplest case, the number of degrees of freedom equals your sample size minus the number of parameters you need to estimate . Again, the exact formula depends on the t-test you want to perform — check the sections below for details.
The degrees of freedom are essential, as they determine the distribution followed by your T-score (under the null hypothesis). If there are d degrees of freedom, then the distribution of the test statistics is the t-Student distribution with d degrees of freedom . This distribution has a shape similar to N(0,1) (bell-shaped and symmetric) but has heavier tails . If the number of degrees of freedom is large (>30), which generically happens for large samples, the t-Student distribution is practically indistinguishable from N(0,1).
💡 The t-Student distribution owes its name to William Sealy Gosset, who, in 1908, published his paper on the t-test under the pseudonym "Student". Gosset worked at the famous Guinness Brewery in Dublin, Ireland, and devised the t-test as an economical way to monitor the quality of beer. Cheers! 🍺🍺🍺
Recall that the p-value is the probability (calculated under the assumption that the null hypothesis is true) that the test statistic will produce values at least as extreme as the T-score produced for your sample . As probabilities correspond to areas under the density function, p-value from t-test can be nicely illustrated with the help of the following pictures:
The following formulae say how to calculate p-value from t-test. By cdf t,d we denote the cumulative distribution function of the t-Student distribution with d degrees of freedom:
p-value from left-tailed t-test:
p-value = cdf t,d (t score )
p-value from right-tailed t-test:
p-value = 1 − cdf t,d (t score )
p-value from two-tailed t-test:
p-value = 2 × cdf t,d (−|t score |)
or, equivalently: p-value = 2 − 2 × cdf t,d (|t score |)
However, the cdf of the t-distribution is given by a somewhat complicated formula. To find the p-value by hand, you would need to resort to statistical tables, where approximate cdf values are collected, or to specialized statistical software. Fortunately, our t-test calculator determines the p-value from t-test for you in the blink of an eye!
Recall, that in the critical values approach to hypothesis testing, you need to set a significance level, α, before computing the critical values , which in turn give rise to critical regions (a.k.a. rejection regions).
Formulas for critical values employ the quantile function of t-distribution, i.e., the inverse of the cdf :
Critical value for left-tailed t-test: cdf t,d -1 (α)
critical region:
(-∞, cdf t,d -1 (α)]
Critical value for right-tailed t-test: cdf t,d -1 (1-α)
[cdf t,d -1 (1-α), ∞)
Critical values for two-tailed t-test: ±cdf t,d -1 (1-α/2)
(-∞, -cdf t,d -1 (1-α/2)] ∪ [cdf t,d -1 (1-α/2), ∞)
To decide the fate of the null hypothesis, just check if your T-score lies within the critical region:
If your T-score belongs to the critical region , reject the null hypothesis and accept the alternative hypothesis.
If your T-score is outside the critical region , then you don't have enough evidence to reject the null hypothesis.
Choose the type of t-test you wish to perform:
A one-sample t-test (to test the mean of a single group against a hypothesized mean);
A two-sample t-test (to compare the means for two groups); or
A paired t-test (to check how the mean from the same group changes after some intervention).
Two-tailed;
Left-tailed; or
Right-tailed.
This t-test calculator allows you to use either the p-value approach or the critical regions approach to hypothesis testing!
Enter your T-score and the number of degrees of freedom . If you don't know them, provide some data about your sample(s): sample size, mean, and standard deviation, and our t-test calculator will compute the T-score and degrees of freedom for you .
Once all the parameters are present, the p-value, or critical region, will immediately appear underneath the t-test calculator, along with an interpretation!
The null hypothesis is that the population mean is equal to some value μ 0 \mu_0 μ 0 .
The alternative hypothesis is that the population mean is:
One-sample t-test formula :
Number of degrees of freedom in t-test (one-sample) = n − 1 n-1 n − 1 .
The null hypothesis is that the actual difference between these groups' means, μ 1 \mu_1 μ 1 , and μ 2 \mu_2 μ 2 , is equal to some pre-set value, Δ \Delta Δ .
The alternative hypothesis is that the difference μ 1 − μ 2 \mu_1 - \mu_2 μ 1 − μ 2 is:
In particular, if this pre-determined difference is zero ( Δ = 0 \Delta = 0 Δ = 0 ):
The null hypothesis is that the population means are equal.
The alternate hypothesis is that the population means are:
Formally, to perform a t-test, we should additionally assume that the variances of the two populations are equal (this assumption is called the homogeneity of variance ).
There is a version of a t-test that can be applied without the assumption of homogeneity of variance: it is called a Welch's t-test . For your convenience, we describe both versions.
Use this test if you know that the two populations' variances are the same (or very similar).
Two-sample t-test formula (with equal variances) :
where s p s_p s p is the so-called pooled standard deviation , which we compute as:
Number of degrees of freedom in t-test (two samples, equal variances) = n 1 + n 2 − 2 n_1 + n_2 - 2 n 1 + n 2 − 2 .
Use this test if the variances of your populations are different.
Two-sample Welch's t-test formula if variances are unequal:
The number of degrees of freedom in a Welch's t-test (two-sample t-test with unequal variances) is very difficult to count. We can approximate it with the help of the following Satterthwaite formula :
Alternatively, you can take the smaller of n 1 − 1 n_1 - 1 n 1 − 1 and n 2 − 1 n_2 - 1 n 2 − 1 as a conservative estimate for the number of degrees of freedom.
🔎 The Satterthwaite formula for the degrees of freedom can be rewritten as a scaled weighted harmonic mean of the degrees of freedom of the respective samples: n 1 − 1 n_1 - 1 n 1 − 1 and n 2 − 1 n_2 - 1 n 2 − 1 , and the weights are proportional to the standard deviations of the corresponding samples.
As we commonly perform a paired t-test when we have data about the same subjects measured twice (before and after some treatment), let us adopt the convention of referring to the samples as the pre-group and post-group.
The null hypothesis is that the true difference between the means of pre- and post-populations is equal to some pre-set value, Δ \Delta Δ .
The alternative hypothesis is that the actual difference between these means is:
Typically, this pre-determined difference is zero. We can then reformulate the hypotheses as follows:
The null hypothesis is that the pre- and post-means are the same, i.e., the treatment has no impact on the population .
The alternative hypothesis:
Paired t-test formula
In fact, a paired t-test is technically the same as a one-sample t-test! Let us see why it is so. Let x 1 , . . . , x n x_1, ... , x_n x 1 , ... , x n be the pre observations and y 1 , . . . , y n y_1, ... , y_n y 1 , ... , y n the respective post observations. That is, x i , y i x_i, y_i x i , y i are the before and after measurements of the i -th subject.
For each subject, compute the difference, d i : = x i − y i d_i := x_i - y_i d i := x i − y i . All that happens next is just a one-sample t-test performed on the sample of differences d 1 , . . . , d n d_1, ... , d_n d 1 , ... , d n . Take a look at the formula for the T-score :
Δ \Delta Δ — Mean difference postulated in the null hypothesis;
n n n — Size of the sample of differences, i.e., the number of pairs;
x ˉ \bar{x} x ˉ — Mean of the sample of differences; and
s s s — Standard deviation of the sample of differences.
Number of degrees of freedom in t-test (paired): n − 1 n - 1 n − 1
We use a Z-test when we want to test the population mean of a normally distributed dataset, which has a known population variance . If the number of degrees of freedom is large, then the t-Student distribution is very close to N(0,1).
Hence, if there are many data points (at least 30), you may swap a t-test for a Z-test, and the results will be almost identical. However, for small samples with unknown variance, remember to use the t-test because, in such cases, the t-Student distribution differs significantly from the N(0,1)!
🙋 Have you concluded you need to perform the z-test? Head straight to our z-test calculator !
A t-test is a widely used statistical test that analyzes the means of one or two groups of data. For instance, a t-test is performed on medical data to determine whether a new drug really helps.
Different types of t-tests are:
To find the t-value:
Choose test type
t-test for the population mean, μ, based on one independent sample . Null hypothesis H 0 : μ = μ 0
Alternative hypothesis H 1
Significance level α
The probability that we reject a true H 0 (type I error).
Degrees of freedom
Calculated as sample size minus one.
Calcworkshop
// Last Updated: October 9, 2020 - Watch Video //
Did you know that the two sample t test is used to calculate the difference between population means?
Jenn, Founder Calcworkshop ® , 15+ Years Experience (Licensed & Certified Teacher)
It’s true!
Now, there 3 ways to calculate the difference between means, as listed below:
Let’s find out more!
So how do we compare the mean of some quantitative variables for two different populations?
If our parameters of interest are the population means , then the best approach is to take random samples from both populations and compare their sample means as noted on the Engineering Statistics Handbook .
In other words , we analyze the difference between two sample means to understand the average difference between the two populations. And as always, the larger the sample size the more accurate our inferences will be.
Just like we saw with one-sample means , we will either employ a z-test or t-test depending on whether or not the population standard deviation is known or unknown .
However, there is a component we must consider, if we have independent random samples where the population standard deviation is unknown – do we pool our variances ?
When we found the difference of population proportions, we automatically pooled our variances. However, with the difference of population means, we will have to check. We do this by finding an F-statistic .
If this F-statistic is less than or equal to the critical number, then we will pool our variances. Otherwise, we will not pool.
Please note, that it is infrequent to have two independent samples with equal, or almost equal, variances — therefore, the formula for un-pooled variations is more readily accepted for most high school statistics courses.
But it is an important skill to learn and understand, so we will be working through several examples of when we need to pool variances and when we do not.
For example, imagine the college provost at one school said their students study more, on average than those at the neighboring school.
However, the provost at the nearby school believed the study time was the same and wants to clear up the controversy.
So, independent random samples were taken from both schools, with the results stated below. And at a 5% significance level, the following significance test is conducted.
Two Sample T Test Pooled Example
Notice that we pooled our variances because our F-statistic yielded a value less than our critical value. The interpretation of our results are as follows:
But what do we do if the populations we wish to compare are not different but the same?
Meaning, the difference between means is due to the population’s varying conditions and not due to the experimental units in the study.
When this happens, we have what is called a Matched Pairs T Test .
The great thing about a paired t test is that it becomes a one-sample t-test on the differences.
And then we will calculate the sample mean and sample standard deviation, sometimes referred to as standard error, using these difference values.
Matched Pairs T Test Formula
What is important to remember with any of these tests, whether it be a z-test or a two-sample t-test, our conclusions will be the same as a one-sample test.
For example, once we find out the test statistic, we then determine our p-value, and if our p-value is less than or equal to our significance level, we will reject our null hypothesis.
One Sample Flow Chart
Two Sample Flow Chart
As the flow chart demonstrates above, our first step is to decide what type of test we are conducting. Is the standard deviation known? Do we have a one sample test or a two sample test or is it matched-pair?
Then, once we have identified the test we are using, our procedure is as follows:
Together, we will work through various examples of all different hypothesis tests for the difference in population means, so we become comfortable with each formula and know why and how to use them effectively.
1 hr 22 min
Get access to all the courses and over 450 HD videos with your subscription
Monthly and Yearly Plans Available
Get My Subscription Now
Still wondering if CalcWorkshop is right for you? Take a Tour and find out how a membership can take the struggle out of learning math.
Chapter 15 hypothesis testing: two sample tests, 15.1 two sample t test.
We can also use the t test command to conduct a hypothesis test on data where we have samples from two populations. To introduce this lets consider an example from sports analytics. In particular, let us consider the NBA draft and the value of a lottery pick in the draft. Teams which do make the playoffs are entered into a lottery to determine the order of the top picks in the draft for the following year. These top 14 picks are called lottery picks.
Using historical data we might want to investigate the value of a lottery pick against those players who were selected outside the lottery.
We can now make a boxplot comparing the career scoring averages of the lottery picks between these two pick levels.
From this boxplot we notice that the lottery picks tend to have a higher point per game (PPG) average. However, we certainly see many exceptions to this rule. We can also compute the averages of the PTS column for these two groups:
Lottery.Pick | ppg | NumberPlayers |
---|---|---|
Lottery | 11.236927 | 371 |
Not Lottery | 7.107924 | 366 |
This table once again demonstrates that the lottery picks tend to average more points. However, we might like to test this trend to see if have sufficient evidence to conclude this trend is real (this could also just be a function of sampling error).
Our first technique for looking for a difference between our two categories is linear regression with a categorical explanatory variable. We fit a regression model of the form: \[PTS=\beta \delta_{\text{ not lottery}}+\alpha\] Where \(\delta_{\text{ not lottery}}\) is equal to one if the draft pick fell outside the lottery and zero otherwise.
To see if this relationship is real we can form a confidence interval for the coefficients.
From this we can see that Lottery picks to tend to average more point per game over their careers. The magnitude of this effect is somewhere between 3.5 and 4.7 points more for lottery picks.
For this we can use the two-sample t-test to compare the means of these two distinct populations.
Here the alternative hypothesis is that the lottery players score more points \[H_A: \mu_L > \mu_{NL}\] thus the null hypothesis is \[H_0: \mu_L \leq \mu_{NL}.\] We can now perform the test in R using the same t.test command as before.
Notice that I used the magic tilde ~ to split the PTS column into the lottery/non-lottery pick subdivisions. I could also do this manually and get the same answer:
The very small p-value here indicates that the population mean of the lottery picks is truly greater than the population mean of the non-lottery picks.
The 95% confidence interval also tells us that this difference is rather large (at least 3.85 points).
Conditions for using a two-sample t test:
These are roughly the same as the conditions for using a one sample t test, although we now need to assume that BOTH samples satisfy the conditions.
Must be looking for a difference in the population means (averages)
30 or greater samples in both groups (CLT)
At this point you would probably like to know why we would ever want to do a two sample t test instead of a linear regression?
My answer is that a two sample t test is more robust against a difference in variance between the two groups. Recall, that one of the assumptions of simple linear regression is that the variance of the residuals does not depend on the explanatory variable(s). By default R does a type of t test which does not assume equal variance between the two groups. This is the one advantage of using the t test command.
Lets say we are trying to estimate the effect of a new training regiment on the 40 yard dash times for soccer players. Before implementing the training regime we measure the 40 yard dash times of the 30 players. First lets read this data set into R.
First, we can compare the mean times before and after the training:
Also we could make a side by side boxplot for the soccer players times before and after the training
We could do a simple t test to examine whether mean of the players times after the training regime is implemented decrease (on average). Here we have the alternative hypothesis that \(H_a: \mu_b-\mu_a>0\) and thus the null hypothesis that \(H_0: \mu_b-\mu_a \leq 0\) . Using the two sample t test format in R we have:
Here we cannot reject the null hypothesis that the training had no effect on the players sprinting performance. However, we haven’t used all of the information available to us in this scenario. The t test we have just run doesn’t know that we recorded the before and after for the same players more than once. As far as R knows the before and after times could be entirely different players as if we are comparing the results between one team which received the training and one who didn’t. Therefore, R has to be pretty conservative in its predictions. The differences between the two groups could be due to many reasons other than the training regime implemented. Maybe the second set of players just started off being a little bit faster, etc.
The data we collected is actually more powerful because we know the performance of the same players before and after the test. This greatly reduces the number of variables which need to be accounted for in our statistical test. Luckily, we can easily let R know that our data points are paired .
Setting the paired keyword to true lets R know that the two columns should be paired together during the test. We can see that running the a paired t test gives us a much smaller p value. Moreover, we can now safely conclude that the new training regiment is effective in at least modestly reducing the 40 yard dash times of the soccer players.
This is our first example of the huge subject of experimental design which is the study of methods which can be used to create data sets which have more power to distinguish differences between groups. Where possible it is better to collect data for the same subjects under two conditions as this will allow for more powerful statistical analysis of the data (i.e a paired t test instead of a normal t test).
Whenever the assumptions are met for a paired t test, you will be expected to perform a paired t test in this class.
We can also use statistical hypothesis testing to compare the proportion between two samples. For example, we might conduct a survey of 100 smokers and 50 non-smokers to see whether they buy organic foods. If we find that 30/100 smokers buy organic and only 11/50 non-smokers buy organic then can we conclude that more smokers buy organic foods that smokers? \(H_a: p_s > p_n\) and \(H_0: p_s \leq p_n\) .
In this case we don’t have sufficient evidence to conclude that a larger fraction of smokers buy organic foods. It is common when analyzing survey data to want to compare proportions between populations.
The key assumptions when performing a two-sample proportion test are that we have at least 5 successes and 5 failures in BOTH samples.
For this example we are going to use a data from a study on the risk factors associated with giving birth to a low-weight baby (sometimes defined as less than 2,500 grams). This data set is another one which is build into R . To load this data for analysis type:
You can view all a description of the data by typing ?birthwt once it is loaded. To begin we could look at the raw birth weight of mothers who were smokers versus non-smokers. We can do some EDA on this data using a boxplot:
From the boxplot we can see that the median birth weight of babies whose mothers smoked was smaller. We can test the data for a difference in the means using a t.test command.
Notice we can use the ~ shorthand to split the data into those two groups faster than filtering. Here we get a small p value meaning we have sufficient evidence to reject the null hypothesis that the mean weight of babies of women who smoked is greater than or equal to those of non-smokers.
Within this data set we also have a column low which classifies whether the babies birth weight is considered low using the medical criterion (birth weight less than 2,500 grams):
We can see that smoking gives a higher fraction of low-weight births. However, this could just be due to sampling error so let’s run a proportion test to find out.
Once again we find we have sufficient evidence to reject the null hypothesis that smoking does not increase the risk of a low birth weight.
15.4.1 concept questions.
For each of the scenarios below form the null and alternative hypothesis.
For the below question work out the number of errors in the data set.
Load the drug_use data set from the fivethirtyeight package. Run a hypothesis test to determine if a larger proportion of 22-23 year olds are using marijuana then 24-25 year olds. Interpret your results statistically and practically.
Import the data set Cavaliers_Home_Away_2016 . Form a hypothesis on whether being home or away for the game had an effect on the proportion of games won by the Cavaliers during the 2016-2017 season, test this hypothesis using a hypothesis test.
Load the data set animal_sleep and compare the average total sleep time (sleep_total column) between carnivores and herbivores (using the vore column) to divide the between the two categories. To begin make a boxplot to compare the total sleep time between these two categories. Do we have sufficient evidence to conclude the average total sleep time differs between these groups?
Load the HR_Employee_Attrition data set. We wish to investigate whether the daily rate (pay) has anything to do with whether a employee has quit (the attrition column is “Yes”). To begin make a boxplot of the DailyRate column split into these Attrition categories. Use the boxplot to help form the null hypothesis for your test and decide on an alternative hypothesis. Conduct a statistical hypothesis test to determine if we have sufficient evidence to conclude that those employees who quit tended to be paid less. Report and interpret the p value for your test.
Load the BirdCaptureData data set. Perform a hypothesis test to determine if the proportion of orange-crowned warblers (SpeciesCode==OCWA) caught at the station is truly less than the proportion of Yellow Warblers (SpeciesCode==YWAR). Report your p value and interpret the results statistically and practically.
(All of Statistics Problem) In 1861, 10 essays appeared in the New Orleans Daily Crescent. They were signed “Quintus Curtius Snodgrass” and one hypothesis is that these essays were written by Mark Twain. One way to look for similarity between writing styles is to compare the proportion of three letter words found in two works. For 8 Mark Twain essays we have:
From 10 Snodgrass essays we have that:
Consider the analysis of the kidiq data set again.
Instructions : Use this T-Test Calculator for two Independent Means calculator to conduct a t-test for two population means (\(\mu_1\) and \(\mu_2\)), with unknown population standard deviations. This test apply when you have two-independent samples, and the population standard deviations \(\sigma_1\) and \(\sigma_2\) and not known. Please select the null and alternative hypotheses, type the significance level, the sample means, the sample standard deviations, the sample sizes, and the results of the t-test for two independent samples will be displayed for you:
More about the t-test for two means so you can better interpret the output presented above: A t-test for two means with unknown population variances and two independent samples is a hypothesis test that attempts to make a claim about the population means (\(\mu_1\) and \(\mu_2\)).
More specifically, a t-test uses sample information to assess how plausible it is for the population means \(\mu_1\) and \(\mu_2\) to be equal. The test has two non-overlapping hypotheses, the null and the alternative hypothesis.
The null hypothesis is a statement about the population means, specifically the assumption of no effect, and the alternative hypothesis is the complementary hypothesis to the null hypothesis.
The main properties of a two sample t-test for two population means are:
The formula for a t-statistic for two population means (with two independent samples), with unknown population variances shows us how to calculate t-test with mean and standard deviation and it depends on whether the population variances are assumed to be equal or not. If the population variances are assumed to be unequal, then the formula is:
On the other hand, if the population variances are assumed to be equal, then the formula is:
Normally, the way of knowing whether the population variances must be assumed to be equal or unequal is by using an F-test for equality of variances.
With the above t-statistic, we can compute the corresponding p-value, which allows us to assess whether or not there is a statistically significant difference between two means.
This is because the samples are not related with each other, in a way that the outcomes from one sample are unrelated from the other sample. If the samples are related (for example, you are comparing the answers of husbands and wives, or identical twins), you should use a t-test for paired samples instead .
The main purpose of this calculator is for comparing two population mean when sigma is unknown for both populations. In case that the population standard deviations are known, then you should use instead this z-test for two means .
Reset password.
H : | |
H : | |
Test Statistic: | and are the sample sizes, where |
Significance Level: | . |
Critical Region: | Reject the null hypothesis that the two means are equal if | > /2, where /2, is the of the distribution with degrees of freedom where If equal variances are assumed, then ν = + - 2 --> |
Alternative Hypothesis | Rejection Region |
---|---|
H : μ ≠ μ | | | > |
H : μ > μ | > |
H : μ |
If you're seeing this message, it means we're having trouble loading external resources on our website.
If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.
To log in and use all the features of Khan Academy, please enable JavaScript in your browser.
Course: ap®︎/college statistics > unit 11.
Six Sigma Study Guide
Study notes and guides for Six Sigma certification tests
Posted by Ted Hessing
A two sample t hypothesis tests also known as independent t-test is used to analyze the difference between two unknown population means. The Two-sample T-test is used when the two small samples (n< 30) are taken from two different populations and compared. The underlying chart makes use of the T distribution.
The two sample t test most likely used to compare two process means, when the data is having one nominal variable and one measurement variable. It is a hypothesis test of means. Use two sample Z test if the sample size is more than 30.
The two sample hypothesis t tests is used to compare two population means, while analysis of variance ( ANOVA ) is the best option if more than two group means to be compared.
Two sample T hypotheis tests are performed when the two group samples are statistically independent to each other, while the paired t-test is used to compare the means of two dependent or paired groups.
The best method to determine population variance is equal or unequal by using an appropriate F-test .
A tailed hypothesis is an assumption about a population parameter. The assumption may or may not be true. One-tailed hypothesis is a test of hypothesis where the area of rejection is only in one direction. Whereas two-tailed, the area of rejection is in two directions. The selection of one or two-tailed tests depends upon the problem.
Two Sample T test mostly performed in Analyze phase of DMAIC to evaluate the difference between two process means are really significant or due to random chance, this is basically used to validate the root cause(s) or Critical Xs (see the below example for more detail)
Example: Apple orchard farm owner wants to compare the two farms to see if there are any weight difference in the apples. From farm A, randomly collected 15 apples with an average weight of 86 gms, and the standard deviation is 7. From farm B, collected 10 apples with an average weight of 80 gms and standard deviation of 8. With a 95% confidence level, is there any difference in the farms?
Significance level: α=0.05
Degrees of freedom df: 15+10-2= 23
Calculate critical value
Refer two tailed t table for 23 degrees of freedom
If the calculated t value is less than -2.069 or greater than 2.069, then reject the null hypothesis.
Compare t calc to t critical . In hypothesis testing, a critical value is a point on the test distribution compares to the test statistic to determine whether to reject the null hypothesis. Calculated t statistic value less than the critical value, hence failed to reject null hypothesis ( H 0 ). So, there is no significant difference between mean weights of apples in farm A and farm B.
Unlock additional members-only content, thank you for being a member, two sample t hypothesis test (unequal variance) videos.
I originally created SixSigmaStudyGuide.com to help me prepare for my own Black belt exams. Overtime I've grown the site to help tens of thousands of Six Sigma belt candidates prepare for their Green Belt & Black Belt exams. Go here to learn how to pass your Six Sigma exam the 1st time through!
In the blood pressure question, can you please explain how you got 7.3 for s? No matter what I do, I am always getting to 7.08
Thanks for the head’s up, Jeremy. I see an opportunity for improvement on both of the examples listed. I’ll update asap.
I added additional detail in the calculation steps.
For these equations with so many variables I find it helpful to go slowly and write out the smaller operations of each part of the calculation.
Does this make sense?
the above states formula for Sample Variation as S2 = {( X Bar– x1)2 + (X Bar – x2)2 + … +(X Bar – xn)2} / n
however the IASSC Reference document is stating
S2 = {( X Bar– x1)2 + (X Bar – x2)2 + … +(X Bar – xn)2} / n-1
Could you please clarify
Thanks Maria
Thank you Maria,
When we divide by n in the sample variance S2, it is not an unbiased estimate of the population variance. Hence it is always recommended to use n-1 instead of n.
I have updated the formula
The formula for Two Sample T Hypothesis Test (Unequal Variance) formula that you have doesn’t match the formula shown on the IASSC formula sheet. Specifically A = sqrt(s1^2/n1), B = sqrt(s2^2/n2) and the way you’ve shown it you have A = s1^2/n1, B = s2^2/n2. Please update.
Hello Gariel Smith,
The formula and calculations are correct, we cross-checked with the Quality Council of Indiana Book as well as the below websites.
https://www.real-statistics.com/students-t-distribution/two-sample-t-test-uequal-variances/
https://www.theopeneducator.com/doe/hypothesis-Testing-Inferential-Statistics-Analysis-of-Variance-ANOVA/Two-Sample-T-Test-Unequal-Variance
Thanks Ramana
Your email address will not be published. Required fields are marked *
This site uses Akismet to reduce spam. Learn how your comment data is processed .
Enter the destination URL
Or link to existing content
COMMENTS
Fortunately, a two sample t-test allows us to answer this question. Two Sample t-test: Formula. A two-sample t-test always uses the following null hypothesis: H 0: μ 1 = μ 2 (the two population means are equal) The alternative hypothesis can be either two-tailed, left-tailed, or right-tailed:
Two-Sample T Test Hypotheses. Null hypothesis (H 0): Two population means are equal (µ 1 = µ 2). Alternative hypothesis (H A): Two population means are not equal (µ 1 ≠ µ 2). Again, when the p-value is less than or equal to your significance level, reject the null hypothesis. The difference between the two means is statistically significant.
How Two-Sample T-tests Calculate T-Values. Use the 2-sample t-test when you want to analyze the difference between the means of two independent samples. This test is also known as the independent samples t-test. Click the link to learn more about its hypotheses, assumptions, and interpretations. Like the other t-tests, this procedure reduces ...
The results for the two-sample t-test that assumes equal variances are the same as our calculations earlier. The test statistic is 2.79996. The software shows results for a two-sided test and for one-sided tests. The two-sided test is what we want (Prob > |t|). Our null hypothesis is that the mean body fat for men and women is equal.
Fortunately, a two sample t-test allows us to answer this question. Two Sample t-test: Formula. A two-sample t-test always uses the following null hypothesis: H 0: μ 1 = μ 2 (the two population means are equal) The alternative hypothesis can be either two-tailed, left-tailed, or right-tailed:
Revised on June 22, 2023. A t test is a statistical test that is used to compare the means of two groups. It is often used in hypothesis testing to determine whether a process or treatment actually has an effect on the population of interest, or whether two groups are different from one another. t test example.
Independent Samples T Tests Hypotheses. Independent samples t tests have the following hypotheses: Null hypothesis: The means for the two populations are equal. Alternative hypothesis: The means for the two populations are not equal.; If the p-value is less than your significance level (e.g., 0.05), you can reject the null hypothesis. The difference between the two means is statistically ...
And let's assume that we are working with a significance level of 0.05. So pause the video, and conduct the two sample T test here, to see whether there's evidence that the sizes of tomato plants differ between the fields. Alright, now let's work through this together. So like always, let's first construct our null hypothesis.
If that's below your significance level, then you would reject your null hypothesis and it would suggest the alternative that might be that, "Hey, maybe this mean "is greater than zero." On the other hand, a two-sample T test is where you're thinking about two different populations. For example, you could be thinking about a population of men ...
The independent t-test, also called the two sample t-test, independent-samples t-test or student's t-test, is an inferential statistical test that determines whether there is a statistically significant difference between the means in two unrelated groups. ... The null hypothesis for the independent t-test is that the population means from the ...
First of all, if you have two groups, one testing one placebo, then it's 2 samples. If it is the same group before and after, then paired t-test. I'm trying to run a dependent sample t-test/paired sample t test through using data from a Qualtrics survey measuring two groups of people (one with social anxiety and one without on the effects of ...
The 2-sample t-test takes your sample data from two groups and boils it down to the t-value. The process is very similar to the 1-sample t-test, and you can still use the analogy of the signal-to-noise ratio. Unlike the paired t-test, the 2-sample t-test requires independent groups for each sample. The formula is below, and then some discussion.
A one-sample t-test (to test the mean of a single group against a hypothesized mean); A two-sample t-test (to compare the means for two groups); or. A paired t-test (to check how the mean from the same group changes after some intervention). Decide on the alternative hypothesis: Two-tailed; Left-tailed; or. Right-tailed.
00:37:48 - Create a two sample t-test and confidence interval with pooled variances (Example #4) 00:51:23 - Construct a two-sample t-test (Example #5) 00:59:47 - Matched Pair one sample t-test (Example #6) 01:09:38 - Use a match paired hypothesis test and provide a confidence interval for difference of means (Example #7) Practice ...
15.1 Two Sample t test. We can also use the t test command to conduct a hypothesis test on data where we have samples from two populations. To introduce this lets consider an example from sports analytics. In particular, let us consider the NBA draft and the value of a lottery pick in the draft. Teams which do make the playoffs are entered into ...
The t-test for dependent samples is a statistical test for comparing the means from two dependent populations (or the difference between the means from two populations). The t-test is used when the differences are normally distributed. The samples also must be dependent. The formula for the t-test statistic is: t = D¯−μD (SD n√) t = D ...
If this is not the case, you should instead use the Welch's t-test calculator. To perform a two sample t-test, simply fill in the information below and then click the "Calculate" button. Enter raw data Enter summary data. Sample 1. 301, 298, 295, 297, 304, 305, 309, 298, 291, 299, 293, 304. Sample 2.
The T-test for Two Independent Samples More about the t-test for two means so you can better interpret the output presented above: A t-test for two means with unknown population variances and two independent samples is a hypothesis test that attempts to make a claim about the population means (\(\mu_1\) and \(\mu_2\)).
The two-sample t-test (Snedecor and Cochran, 1989) is used to determine if two population means are equal. A common application is to test if a new process or treatment is superior to a current process or treatment. ... In this case, we can state the null hypothesis in the form that the difference between the two populations means is equal to ...
Writing hypotheses to test the difference of means. An exercise scientist wanted to test the effectiveness of a new program designed to increase the flexibility of senior citizens. They recruited participants and rated their flexibility according to a standard scale before starting the program. The participants all went through the program and ...
by Zach Bobbitt August 3, 2022. A two sample t-test is used to test whether or not the means of two populations are equal. You can use the following basic syntax to perform a two sample t-test in R: t.test(group1, group2, var.equal=TRUE) Note: By specifying var.equal=TRUE, we tell R to assume that the variances are equal between the two samples.
A two sample t hypothesis tests also known as independent t-test is used to analyze the difference between two unknown population means. The Two-sample T-test is used when the two small samples (n< 30) are taken from two different populations and compared. The underlying chart makes use of the T distribution.
In statistics, Welch's t-test, or unequal variances t-test, is a two-sample location test which is used to test the (null) hypothesis that two populations have equal means. It is named for its creator, Bernard Lewis Welch, and is an adaptation of Student's t-test, and is more reliable when the two samples have unequal variances and possibly unequal sample sizes.