# The Difference between Two Means

Site: | Saylor Academy |

Course: | MA121: Introduction to Statistics |

Book: | The Difference between Two Means |

Printed by: | Guest user |

Date: | Saturday, August 10, 2024, 6:36 PM |

## Description

This section covers how to test for differences between means from two separate groups of subjects and gives an example of opinions on animal research. The detailed testing procedure is carried out using the standard steps in hypothesis testing.

## Difference between Two Means (Independent Groups)

#### Learning Objectives

- State the assumptions for testing the difference between two means
- Estimate the population variance assuming homogeneity of variance
- Compute the standard error of the difference between means
- Compute t and p for the difference between means
- Format data for computer analysis

It is much more common for a researcher to be interested in the difference between means than in the specific values of the means themselves. This section covers how to test for differences between means from two separate groups of subjects. A later section describes how to test for differences between the means of two conditions in designs where only one group of subjects is used and each subject is tested in each condition.

We take as an example the data from the "Animal Research" case study. In this experiment, students rated (on a 7-point scale) whether they thought animal research is wrong. The sample sizes, means, and variances are shown separately for males and females in Table 1.

Table 1. Means and Variances in Animal Research study.

Group | n | Mean | Variance |
---|---|---|---|

Females | 17 | 5.353 | 2.743 |

Males | 17 | 3.882 | 2.985 |

As you can see, the females rated animal research as more wrong than did the males. This sample difference between the female mean of 5.35 and the male mean of 3.88 is 1.47. However, the gender difference in this particular sample is not very important. What is important is whether there is a difference in the *population *means.

In order to test whether there is a difference between population means, we are going to make three assumptions:

- The two populations have the same variance. This assumption is called the assumption of homogeneity of variance.
- The populations are
*normally distributed*. - Each value is sampled
*independently*from each other value. This assumption requires that each subject provide only one value. If a subject provides two scores, then the scores are not independent. The analysis of data with two scores per subject is shown in the section on the correlated test later in this chapter.

The consequences of violating the first two assumptions are investigated in the simulation in the next section. For now, suffice it to say that small-to-moderate violations of assumptions 1 and 2 do not make much difference. It is important not to violate assumption 3.

We saw the following general formula for significance testing in the section on testing a single mean:

In this case, our statistic is the difference between sample means and our hypothesized value is 0. The hypothesized value is the null hypothesis that the difference between population means is 0.

We continue to use the data from the "Animal Research" case study and will compute a significance test on the difference between the mean score of the females and the mean score of the males. For this calculation, we will make the three assumptions specified above.

The first step is to compute the statistic, which is simply the difference between means.

Since the hypothesized value is 0, we do not need to subtract it from the statistic.

The next step is to compute the estimate of the standard error of the statistic. In this case, the statistic is the difference between means, so the estimated standard error of the statistic is . Recall from the relevant section in the chapter on sampling distributions that the formula for the standard error of the difference between means is:

In order to estimate this quantity, we estimate and use that estimate in place of Since we are assuming the two population variances are the same, we estimate this variance by averaging our two sample variances. Thus, our estimate of variance is computed using the following formula:

where is our estimate of . In this example,

Since (the number of scores in each group) is 17 ,

The next step is to compute by plugging these values into the formula:

Finally, we compute the probability of getting a as large or larger than 2.533 or as small or smaller than -2.533. To do this, we need to know the degrees of freedom. The degrees of freedom is the number of independent estimates of variance on which is based. This is equal to , where is the sample size of the first group and is the sample size of the second group. For this example, When , it is conventional to use " " to refer to the sample size of each group. Therefore, the degrees of freedom is .

Once we have the degrees of freedom, we can use the distribution calculator to find the probability. Figure 1 shows that the probability value for a two-tailed test is . The two-tailed test is used when the null hypothesis can be rejected regardless of the direction of the effect. As shown in Figure 1, it is the probability of or .

Figure 1. The two-tailed probability.

The results of a one-tailed test are shown in Figure 2. As you can see, the probability value of 0.0082 is half the value for the two-tailed test.

Figure 2. The one-tailed probability.

Source: David M. Lane, https://onlinestatbook.com/2/tests_of_means/difference_means.html

This work is in the Public Domain.

## Formatting Data for Computer Analysis

Most computer programs that compute tests require your data to be in a specific form. Consider the data in Table 2.

Table 2. Example Data.

Group 1 | Group 2 |
---|---|

3 | 2 |

4 | 6 |

5 | 8 |

Here there are two groups, each with three observations. To format these data for a computer program, you normally have to use two variables: the first specifies the group the subject is in and the second is the score itself. The reformatted version of the data in Table 2 is shown in Table 3.

Table 3. Reformatted Data.

G | Y |
---|---|

1 | 3 |

1 | 4 |

1 | 5 |

2 | 2 |

2 | 6 |

2 | 8 |

To use Analysis Lab to do the calculations, you would copy the data and then

- Click the "Enter/Edit Data" button. (You may be warned that for security reasons you must use the keyboard shortcut for pasting data.)
- Paste your data.
- Click "Accept Data".
- Set the Dependent Variable to .
- Set the Grouping Variable to .
- Click the "-test/confidence interval" button.

## Computations for Unequal Sample Sizes (optional)

The calculations are somewhat more complicated when the sample sizes are not equal. One consideration is that MSE, the estimate of variance, counts the group with the larger sample size more than the group with the smaller sample size. Computationally, this is done by computing the sum of squares error (SSE) as follows:

where is the mean for group 1 and is the mean for group 2 . Consider the following small example:

Group 1 | Group 2 |
---|---|

3 | 2 |

4 | 4 |

5 |

where the degrees of freedom (df) is computed as before: MSE

The formula

The formula

is replaced by

where is the harmonic mean of the sample sizes and is computed as follows:

and

Therefore,

##### R code

Data file

data=read.csv(file="animal.csv")

t.test(data$WRONG ~ data$GENDER,var.equal=TRUE)

Two Sample t-test

data: data$WRONG by data$GENDER

t = 2.5335, df = 32, p-value = 0.01639

alternative hypothesis: true difference in means is not equal to 0

95 percent confidence interval:

0.2882231 2.6529534

sample estimates:

mean in group 1 mean in group 2

5.352941 3.882353

## Video

## Questions

**Question 1 out of 9.**

The graphs show a violation of the assumption of (check all that apply)

- normality
- homogeneity of variance

**Question 2 out of 9.**

The graphs show a violation of the assumption of (check all that apply)

- normality
- homogeneity of variance

**Question 3 out of 9.**

The graphs show a violation of the assumption of (check all that apply)

- normality
- homogeneity of variance

**Question 4 out of 9.**

In the formula for , the "statistic" is

- the null hypothesis.
- the mean of all numbers.
- the difference between sample means.
- the significance level.

**Question 5 out of 9.**

In the formula for , the "hypothesized value" is

**Question 6 out of 9.**

If the null hypothesis is that two population means are equal, then the hypothesized value is

- 0.
- the population mean.

**Question 7 out of 9.**

The denominator in the test formula is

- the estimated standard error of the mean.
- the estimated standard error of the difference between means.
- MSE/2

**Question 8 out of 9.**

If there are 4 scores per group and the value is 2.34, what is the value for a two-tailed test (to 3 decimal places)?

___________

**Question 9 out of 9.**

What is the t for an independent-groups test for these data?

___________

G 1 G 2 46 28 59 37 53 40 35 34 43 29 28 46 59 26 51 41

## Answers

- The distributions are skewed and therefore violate the assumption of normality.
- Population 1 is skewed and therefore violates the assumption of normality. Population 2 has a larger variance.
- Population 2 has a larger variance.
- The statistic is the value you are interested in testing. Here you are interested in the difference between means.
- The hypothesized value is the population parameter you are comparing your statistic to. Here you are interested in the difference between population means.
- If the population means are equal, then the hypothesized value of the difference between means is 0.
- Since the statistic in question is the difference between means, the denominator is the estimated standard error of the difference between means.
- The is The value is
- Compute the for an independent-groups test. If you are using a program, make sure to recode the data as described.