Login
📚 Mostly Harmless Statistics
Chapters ▾
⇩ Download ▾

9.2 Two Independent Groups

This section will look at how to analyze a difference in the mean for two independent samples. As with all other hypothesis tests and confidence intervals, the process is the same, though the formulas and assumptions are different.

The symbol used for the population mean has been μ up to this point. In order to use formulas that compare the means from two populations, we use subscripts to show which population statistic or parameter we are referencing.

Parameters

Statistics

You do not need to use the subscripts 1 and 2. You can use a letter or symbol that helps you differentiate between the two groups. For instance, if you have two manufacturers labeled A and B, you may want to use µA and µB.

When setting up the null hypothesis we are testing if there is a difference in the two means equal to some known difference. H0: µ1 – µ2 = (µ1 – µ2)0. We will focus on the case where (µ1 – µ2)0 = 0, which says that, tentatively, we assume that there is no difference in population means H0: µ1 – µ2 = 0. If we were to subtract μ2 from both sides of the equation µ1 – µ2 = 0 we would get µ1 = µ2. For instance, if the average age for group one was 25 and the average age for group two was also 25, then the difference between the two means would be 25 – 25 = 0.

There are three ways to set up the hypotheses for comparing two independent population means µ1 and µ2.

Table of the three hypothesis setups for two independent means: two-tailed with H0: μ1 = μ2 and H1: μ1 ≠ μ2, right-tailed with H1: μ1 > μ2, and left-tailed with H1: μ1 < μ2, each with a normal curve shaded in both tails, the right tail, or the left tail, and the equivalent difference forms H0: μ1 - μ2 = 0 with H1: μ1 - μ2 ≠ 0, > 0, or < 0.

Figure 9-3

For a one-tailed test, one could alternatively write the null hypotheses as:

Right-tailed test Left-tailed test

H0: µ1 ≤ µ2 H0: µ1 ≥ µ2

H1: µ1 > µ2 H1: µ1 < µ2

This text mostly will use an = sign in the null hypothesis.

Most of the time the groups are numbered from the order in which their statistics or data appear in the problem. To keep the correct sign of the test, make sure you do not switch the order of the groups.

For instance, if we were comparing the mean SAT score between high school juniors and seniors and our hypothesis is that the mean for seniors is higher we could set up the alternative hypotheses as either µj < µs if we had the juniors be group 1 and µj > µs if we had the seniors be group 1. This change would switch the sign of both the test statistic and the critical value.

When performing a one-tailed test the sign of the test statistic and critical value will match most of the time. For example, if your test statistic came out to be z = –1.567 and your critical value was z = 1.645 you most likely have the incorrect order in your hypotheses.

When you are making a conjecture about a population mean, we have two different situations, depending on if we know that population standard deviation, or not, called the z-test and t-test, respectively. Use Figure 9-4 to help decide when to use the z-test and t-test.

Flowchart for choosing between the z-test and t-test: from the box Is σ known?, the Yes arrow leads to use the z α/2 values and σ in the formula, and the No arrow to use the t α/2 values and s; a footnote reads that if n < 30, the variable must be normally distributed.

Figure 9-4

Note that you should never use the value of σx on your calculator since you would rarely ever have an entire population of raw data to input into a calculator. The problem may give you raw data, but σ or σ2 would be stated in the problem and you should be using a z-test, otherwise use the t-test with the sample standard deviation sx. Usually, σ is known from a previous year or similar study.

In either case if the sample sizes are below 30 we need to check that the population is approximately normally distributed for the Central Limit Theorem to hold. We can do this with a normal probability plot. Most examples that we deal with just assume the population is normally distributed, but in practice, you should always check these assumptions.

9.3.1 Two Sample Mean Z-Test & Confidence Interval

The traditional method (or critical value method), the p-value method, and the confidence interval method are performed with steps that are identical to those when performing hypothesis tests for one population. We will show an example of a two-sample z-test, but seldom in practice will we perform this type of test since we rarely have access to a population standard deviation.

Two-Sample Z-Interval

For independent samples, we take the mean of each sample, then take the difference in the means. If the means are equal, then the difference of the two means would be equal to zero. We can then compare the null hypothesis, that there is no difference in the means μ1 – μ2 = 0, with the confidence interval limits to decide whether to reject the null hypothesis. If zero is contained within the confidence interval, then we fail to reject H0. If zero is not contained within the confidence interval, then we reject H0.

The requirements for the confidence interval are identical to the previous hypothesis test.

9.3.2 Two Sample Mean T-Test & Confidence Interval

The t-test is a statistical test for comparing the means from two independent populations. The t-test is used when σ1 and/or σ2 are both unknown. The samples must be independent and if the sample sizes are less than 30 then the populations need to be normally distributed. The t-test, as opposed to the z-test, for two independent samples has two different versions depending on if a particular assumption that the unknown population variances are unequal or equal. Since we do not know the true value of the population variances, we usually will use the first version and assume that the population variances are not equal σ12σ22. Both versions are presented, so make sure to check with your instructor if you are using both versions.

9.3.2.a Unequal Variance Method t-Test

Some older calculators only accept the df as an integer, in this case round the df down to the nearest integer if needed. For most technology, you would want to keep the decimal df.

Some textbooks use an approximation for the df as the smaller of n1 – 1 or n2 – 1, so you may find a different answer using your calculator compared to examples found elsewhere.

The traditional method (or critical value method), the p-value method, and the confidence interval method are performed with steps that are identical to those when performing hypothesis tests for one population.

The sample sizes both need to be 30 or more, or the populations need to be approximately normally distributed in order for the Central Limit Theorem to hold.

Two-Sample T-Interval

For independent samples, we take the mean of each sample, then take the difference in the means. If the means are equal, then the difference of the two means would be equal to zero. We can then compare the null hypothesis, that there is no difference in the means μ1 – μ2 = 0, with the confidence interval limits to decide whether to reject the null hypothesis. If zero is contained within the confidence interval, then we fail to reject H0. If zero is not contained within the confidence interval, then we reject H0.

The requirements and degrees of freedom are identical to the above hypothesis test.

Critical Value Method

The hypotheses and test statistic steps do not change compared to the p-value method.

Hypotheses: H0: µ1 = µ2

H1: µ1 ≠ µ2.

Test Statistic: t=(x¯1x¯2)(μ1μ2)0(s12n1+s22n2)=(596.2353481.5)0(163.2362217+179.3957216)=1.9179

Compute the t critical values.

The degrees of freedom stay the same: df=(163.2362217+179.3957216)2((163.2362217)2(116)+(179.3957216)2(115))=30.2598

We can use the t Critical two-tail value given in the Excel output or use the TI-calculator invT(0.05,30.2598) = -1.697. Some older calculators do not let you use a decimal for df so round down and use invT(0.05,30).

TI-84 home screen showing the critical value computation invT(0.05,30) returning -1.697260851.

Figure 9-6.

Normal curve with both tails shaded beyond the critical values -1.697 and 1.697; a blue line marks the test statistic 1.9179, which falls inside the right-tail rejection region.

Figure 9-6

Since the test statistic is in the critical region, we would reject H0. This agrees with the same decision that we had using the p-value method.

Summary: At the 10% level of significance, there is statistically significant difference between the mean electricity use between Sacramento and Portland.

Confidence Interval Method

The hypotheses are the same. The main difference is that we would find a confidence interval and compare H0: µ1 – µ2 = 0 with the endpoints to make the decision.

Hypotheses: H0: µ1 = µ2

H1: µ1 ≠ µ2.

Find the confidence interval. First, compute the tα/2 critical value for a 90% confidence interval since α = 0.10.

Use df=(s12n1+s22n2)2((s12n1)2(1n11)+(s22n2)2(1n21))=(163.2362217+179.3957216)2((163.236217)2(116)+(179.395216)2(115))=30.2598.

The critical value is tα/2 = invT(0.05,30.2598) = –1.697.

The older TI-83 invT program only accepts integer df, use df =30. Alternatively, use the output from the Excel output under the t Critical two-tail row.

Next, find the interval estimate (x¯1x¯2)±tα/2(s12n1+s22n2)

\(\begin{aligned}
&\Rightarrow(596.2353-481.5) \pm 1.697 \sqrt{\left(\frac{163.2362^{2}}{17}+\frac{179.3957^{2}}{16}\right)} \\
&\Rightarrow \quad 114.7353 \pm 101.5203.
\end{aligned}\)

Use interval notation (13.215, 216.2556) or standard notation 13.215 < μ1 – μ2 < 216.2556. Note the calculator does not round between steps and gives a more accurate answer of (13.23, 216.24).

For an interpretation, if we were to use the same sampling techniques, approximately 90 out of 100 times a confidence interval with the same margin of error of (13.23, 216.24) would contain the population mean difference in electricity use between Sacramento and Portland.

We are 90% confident that the population mean household electricity use for Sacramento is between 13.23 and 216.24 kilowatt hours more than Portland households.

Since both endpoints are positive, zero would not be captured in the confidence interval so we would reject H0.

Summary: At the 10% level of significance, there is statistically significant difference between the mean electricity use between Sacramento and Portland.

All 3 methods should yield the same result. This text is only using the two-sided confidence interval.

TI-84: Press the [STAT] key, arrow over to the [TESTS] menu, arrow down to the option [0:2-SampTInt] and press the [ENTER] key. Arrow over to the [Stats] menu and press the [Enter] key. Enter the means, standard deviations, sample sizes, confidence level. Highlight the No option under Pooled for unequal variances. Arrow down to [Calculate] and press the [ENTER] key. The calculator returns the confidence interval.

Or (if you have raw data in list one and list two) press the [STAT] key and then the [EDIT] function, type the data into list one for sample one and list two for sample two. Press the [STAT] key, arrow over to the [TESTS] menu, arrow down to the option [0:2-SampTInt] and press the [ENTER] key. Arrow over to the [Data] menu and press the [ENTER] key. The defaults are List1: L1, List2: L2, Freq1:1, Freq2:1. If these are set different, arrow down and use [2nd] [1] to get L1 and [2nd] [2] to get L2. Then type in the confidence level. Highlight the No option under Pooled for unequal variances. Arrow down to [Calculate] and press the [ENTER] key. The calculator returns the confidence interval.

TI-89: Go to the [Apps] Stat/List Editor, then press [2nd] then F5 [Ints], then select 4: 2-SampTInt. Enter the sample means, sample standard deviations, sample sizes (or list names (list3 & list4), and Freq1:1 & Freq2:1), confidence level. Highlight the No option under Pooled. Press the [ENTER] key to calculate. The calculator returns the confidence interval. If you have the raw data, select Data and enter the list names.

Summary

Use the z-test only if the population variances (or standard deviations) are given in the problem. Most of the time we do not know these values and will use the t-test. A t-test is used for many applications. We use the t-test for a hypothesis test to see if there is a change in the mean between the groups for dependent samples. We can also use the t-test for a hypothesis test to see if there is a change in the mean for independent samples. Be careful which t-test you use, paying attention to the assumption that the variances are equal or not.

9.3.2.b Equal Variance Method t-Test

This method assumes that we know the population’s standard deviations have approximately the same spread. Be careful with this since both populations could be normally distributed and independent, but one population may be way more spread out (larger variance) then the other so you would want to use the unequal variance version. For this text, we will state in the problem whether or not the population’s variances (or standard deviations) are equal. Also, be careful when distinguishing between when to use the z-test versus t-test, just because we assume the population variances or standard deviations are equal does not mean we know their numeric values. We also need to assume the populations are normally distributed if either sample size is below 30.

The value s2=(n11)s12+(n21)s22(n1+n22) under the square root is called the pooled variance and is a weighted mean of the two sample variances, weighted on the corresponding sample sizes.

In some textbooks, they may find the pooled variance first, then place into the formula as t=(x¯1x¯2)(μ1μ2)(s2n1+s2n2).

Note: The df formula matches what your calculator gives you when you select Yes under the Pooled option.

The traditional method (or critical value method), the p-value method, and the confidence interval method are performed with steps that are identical to those when performing hypothesis tests for one population.

TI-84: Press the [STAT] key, arrow over to the [TESTS] menu, arrow down to the option [4:2-SampTTest] and press the [ENTER] key. Arrow over to the [Stats] menu and press the [Enter] key. Enter the means, standard deviations, sample sizes, confidence level. Then arrow over to the not equal, <, > sign that is the same in the problem’s alternative hypothesis statement, then press the [ENTER] key. Highlight the Yes option under Pooled for unequal variances. Arrow down to [Calculate] and press the [ENTER] key. The calculator returns the test statistic and the p-value. If you have raw data, press the [STAT] key and then the [EDIT] function, enter the data into list one and list two. Press the [STAT] key, arrow over to the [TESTS] menu, arrow down to the option [4:2-SampTTest] and press the [ENTER] key. Arrow over to the [Data] menu and press the [ENTER] key. The defaults are List1: L1, List2: L2, Freq1:1, Freq2:1. If these are set different arrow down and use [2nd] [1] to get L1 and [2nd] [2] to get L2.

TI-89: Go to the [Apps] Stat/List Editor, then press [2nd] then F6 [Tests], then select 4: 2-SampT-Test. Enter the sample means, sample standard deviations, and sample sizes (or list names (list3 & list4), and Freq1:1 & Freq2:1). Then arrow over to the not equal, and select the sign that is the same in the problem’s alternative hypothesis statement. Highlight the Yes option under Pooled. Press the [ENTER] key to calculate. The calculator returns the t-test statistic and the p-value.

Two-Sample t-Interval Assuming Equal Variances

For independent samples, we take the mean of each sample, then take the difference in the means. If the means are equal, then the difference of the two means would be equal to zero. We can then compare the null hypothesis, that there is no difference in the means μ1 – μ2 = 0, with the confidence interval limits to decide whether to reject the null hypothesis. If zero is contained within the confidence interval, then we fail to reject H0. If zero is not contained within the confidence interval, then we reject H0.

The requirements and degrees of freedom are identical to the above hypothesis test.

Adapted from Mostly Harmless Statistics by Rachel Webb (Portland State University), hosted on LibreTexts (stats.libretexts.org) and licensed under CC BY-SA 4.0. Changes were made. License: CC-BY-SA-4.0.