Chapter 6 Two Samples Hypothesis Testing (Section on Mar 9th)

Testing on Mean and Variance for Two Samples Test

Definition 6.1 (Independent Samples) Two samples are independent if the sample values selected from one population are not related to or somehow paired or matched with the sample values selected from the other population.

Generally, this kind of problem gives you two groups of randomly sampled data from two normally distributed populations. The task is to test whether the two normal population have the same mean and variance. The test procedure we take is first test whether the variance (Chapter 8-6 on Textbook, start from Page-414), then base on the result to test the mean (Chapter 8-3 on Textbook, start from Page-389).

Definition 6.2 (Test Variance of Two Samples) Let s21 denote the larger of the two sample variances, n1 denote the corresponding sample size, σ21 denote the corresponding population variance. s22,n2,σ22 denote the sample variance, sample size and population variance for the other sample. The two samples variance test is the hypothesis test testing whether σ21 equals σ22. The null and alternative hypothesis is stated below: H0:σ21=σ22H1:σ21σ22 The test statistic is F=s21s22 Since the test statistic follows F distribution under null hypothesis, the critical value should be found with respect to the F distribution table. To get the critrical value, we need to the following three values:

  • Significance level α: usually specified in the problem.

  • Numerator degree of freedom df1: computed by n11.

  • denominator degree of freedom df2: computed by n21

The critircal value is then F1α2,df1,df2. The rejection region is shown in Figure 6.1. The test reject the null hypothesis (conclude σ21σ22) if F computed in (6.2) is greater than F1α2,df1,df2 and fail to reject the null hypothesis (conclude σ21=σ22) if F is smaller than or equal to F1α2,df1,df2.
\label{fig:06001}Two samples variance hypothesis testing reject region

FIGURE 6.1: Two samples variance hypothesis testing reject region

Some tips for this test:

  • Remember in the calculation of F, you need to put the larger sample variance on the numerator. In such a case, you will always get a F value larger than 1. Therefore, it is not necessary to compare your F value with Fα2,df1,df2.

  • To get the correct critrical value, make sure you get the correct degree of freedoms by correctly specify n1 and n2. You also need to judge whether this is a two-tailed test or a one-tailed test.

  • F distribution table can be found as Table A-5 on your textbook or online here.

For two samples mean test, based on the result of variance test, we have two different ways.

Definition 6.3 (Test Mean of Two Samples, When Sample Variance Can Be Assumed Same) Let ˉxi,ni,μi,s2i, i=1,2 denote the sample mean, sample size, population mean and sample variance for two groups. In this test, we usually cares about whether μ1 equals μ2 or not, the two hypotheses is then H0:μ1=μ2H1:μ1μ2 The test statistic is then t=ˉx1ˉx2s2pn1+s2pn2 where s2p=(n11)s21+(n21)s22(n11)+(n21) Since the test statistic follows t distribution under null hypothesis, the critical value should be found with respect to the t distribution table. To get the critrical value, we need to the following two values:

  • Significance level α: usually specified in the problem.

  • Degree of freedom: calculated by df=n1+n22.

The critircal value is then Tα2,df and T1α2,df, which give the rejection region t<Tα2,df or t>T1α2,df. An alternative way to get conclusion is by computing the p-value. The procedure of finding p-value is summarized in Figure 6.2. We reject the null hypothesis if p-value is less than the significance level α.
\label{fig:06002}Procedure of finding p-value

FIGURE 6.2: Procedure of finding p-value

Definition 6.4 (Test Mean of Two Samples, When Sample Variance Can NOT Be Assumed Same) Using the same notation as Definition 6.3, and the hypotheses we are going to test is still H0:μ1=μ2H1:μ1μ2 but now the test statistic changes to t=(ˉx1ˉx2)s21n1+s22n2 To compute the critrical value, after specificing the significance level α, you can either refer to t distribution table with df=min{n11,n21} or standard normal z table. The procedure of drawing conclusion is the same as in Definition 6.3, i.e. you need to calculate p-value.

Requirements for using these tests

  1. The two samples are independent.

  2. Both samples are simple random samples.

  3. Either or both of these conditions is satisfied: The two sample sizes are both large (with n1>30 and n2>30) or both samples come from populations having normal distributions.

Exercise 6.1 The test scores of randomly selected 8 female students and 6 male students are given by the following:

scores for male students: 81,84,89,79,82,90

scores for female students: 85,89,92,94,81,78,89,86.

  1. Assuming the scores of females and males following N(μ1,σ1) distribution and N(μ2,σ2) distribution respectively, test the hypothesis H0:σ1=σ2 vs. H1:σ1σ2. Would you reject H0 at 5% level of significance?

  2. Test H0:μ1=μ2 vs.H1:μ1μ2 and provide the p-value. Would you reject H0 at 5% level of significance?

Proof. (a) We do this test step by step as the text book does.

Step 0: We compute sample variance and sample size for each groups, and denote the group with larger variance as group 1. By doing this wa have s21=29.07,n1=8 and s22=19.77,n2=6.

Step 1: The claim of equal standard deviations is equivalent to a claim of equal variances, which we express symbolically as σ21=σ22.

Step 2: If the original claim is false, then σ21σ22.

Step 3: Because the null hypothesis is the statement of equality and because the alternative hypothesis cannot contain equality, we have H0:σ21=σ22H1:σ21σ22

Step 4: The significance level is α=0.05.

Step 5: Because this test involves two population variances, we use the F distribution.

Step 6: The test statistic is F=s21s22=29.0719.77=1.47 For the critrical value, we also need degree of freedom, which is 7 and 5. Thus, the critrical value is F0.975,7,5=6.85.

Step 7: since F=1.47<6.85, we fail to reject the null hypothesis and conclude that the two sample standard deviation is the same.

  1. We do this follows the steps given by examples on the textbook.

Step 0: The sample mean for group 1 (female students) is ˉx1=86.75, with variance s21=29.07 and sample size n1=8. For group 2 (male students), ˉx2=84.17, s22=19.77 and sample size n2=6.

Step 1: The claim of equal means can be expressed symbolically as μ1=μ2.

Step 2: If the original claim is false, then μ1μ2.

Step 3: The alternative hypothesis is the expression not containing equality, and the null hypothesis is an expression of equality, so we have H0:μ1=μ2H1:μ1μ2

Step 4: The significance level is α=0.05.

Step 5: Because we have two independent samples and we are testing a claim about the two population means, we use a t distribution with the test statistic given earlier in this section.

Step 6: Since we have same variance assumption, we use Definition 6.3 to compute the test statistic as s2p=(n11)s21+(n21)s22(n11)+(n21)=25.195t=ˉx1ˉx2s2pn1+s2pn2=0.88

Step 7: Since the degree of freedom is df=n+m2=12, we calculate p-value, the p-value for this problem as 2(1P(t12<0.88))=0.40>0.05, so we do not reject the null hypothesis and conclude the two sample mean is the same.
There is a typo in the original solutions posted online. The sample variance in that solution is actually sample standard deviation. You need to square it so the following result all changes. The original does not follows the procedure produced on the textbook by putting the group with larger variance on the numerator. It also works but in that case you should calculate critrical value as Fα2,df1,df2 with df1 and df2 switches.

Exercise 6.2 The heights of randomly selected 5 males from country A and 7 males from country B are given by the following:

heights for males in country A: 163,160,159,159,161

heights for males in country B: 149,182,145,143,184,185,140.

  1. Assuming the heights of males from country A and B following N(μ1,σ1) distribution and N(μ2,σ2) distribution respectively, test the hypothesis H0:σ1=σ2 vs. H1:σ1σ2. Would you reject H0 at 5% level of significance?

  2. Test H0:μ1=μ2 vs.H1:μ1μ2 and provide the p-value.

Proof. (a) Since s21=451.81, n1=7, s22=2.8,n2=5, we are testing H0:σ21=σ22 vs. H1:σ21σ22 at significance level α=0.05. The test statistic is F=451.812.8=161.36. The critrical value is F0.975,6,4=9.20, since F>>9.20 we reject the null hypothesis and reject the null hypothesis, concluding that σ1σ2.

For part(b) Since ˉx1=161.14 and ˉx2=160.4, we are testing H0:ˉx1=ˉx2 vs. H1:ˉx1ˉx2 at significance level α=0.05, without assuming same variance. The test statistic is therefore t=(ˉx1ˉx2)s21n1+s22n2=161.14160.4451.817+2.85=0.09 Then you can either compute p-value as 2(1P(Z<0.09))=0.93 or 2(1P(T4<0.09))=0.93, either way you will fail to reject the null hypothesis and conclude the two means are the same.

Testing two proportion

This kind of hypothesis testing problem is discussed in detail in Chapter 8-2 on your textbook (start from Page-379).

Definition 6.5 (Hypothesis Testing for Two Proportions) Let pi,ni,xi,ˆpi, i=1,2 denote the population proportion, sample size, sample number of success, sample proportion for group 1 and 2, respectively. we have ˆpi=xini. Define ˉp=x1+x2n1+n2 and ˉq=1ˉp. To test the hypotheses H0:p1=p2 vs H1:p0p1 we use the test statistic z=ˆp1ˆp2ˉpˉqn1+ˉpˉqn2 This test statistic is refrred to a standard normal distribution under null hypothesis to make conclusion. The rejection region is (,Zα2)(Z1α2,) or we can use p-value to make conclusion. The null hypothesis is reject if the p-value is less than α.

Exercise 6.3 A survey is conducted in the Santa Cruz and Monterey counties to assess the proportion of smokers. Among 600 people surveyed in both counties, 230 and 180 are found to be smokers in the Santa Cruz and Monterey counties respectively.

If p1 and p2 denote the proportion of smokers in the entire SC and Monterey counties respectively, test H0:p1=p2 vs H1:p0p1 under α=0.05.

Proof. We do this step by step as the textbook.

Step 0: Get the numbers from sample data, we have n1=n2=600, x1=230, x2=180, ˆp1=230600=0.38 and ˆp2=180600=0.3.

Step 1: The claim of equal proportion can be expressed symbolically as p1=p2.

Step 2: If the original claim is false, then p1p2.

Step 3: The alternative hypothesis is the expression not containing equality, and the null hypothesis is an expression of equality, so we have H0:p1=p2H1:p1p2

Step 4: The significance level is α=0.05.

Step 5: The reference distribution is standard normal distribution.

Step 6: We calculate test statistic using (6.13) and (6.14) as follow. ˉp=x1+x2n1+n2=230+180600+600=0.34z=ˆp1ˆp2ˉpˉqn1+ˉpˉqn2=0.380.30.34×0.66600+0.34×0.66600=2.93

Step 7: Either compute the reject region as (,Zα2)(Z1α2,)=(,1.96)(1.96,), z is in the rejection region or compute the p-value as 2(1P(Z<2.93))=0.003<0.05. Either method we reject the null hypothesis and conclude that two population proportion is not the same.

Testing of Correlation This kind of hypothesis testing problem is discussed in detail in Chapter 9-2 on your textbook (start from Page-437).

Definition 6.6 (Test of Correlation) Let n denote the number of pairs of data present, r represents the linear correlation coefficient for a sample and ρ represents the linear correlation coefficient for a population. The formula for calculate r is r=nXY(X)(Y)n(X2)(sumX)2n(Y2)(sumY)2 we are testing hypotheses H0:ρ=0 vs H1:ρ0. The test statistic we are using is t=r1r2n2 Under the null hypothesis, this statistic is referred to a t distribution with df=n2. You can either compute reject region defined by (,Tα2,df)(T1α2,df,) or use p-value to draw conclusion.

Exercise 6.4 Theories have been developed about the heights of winning candidates for the U.S. presidency and the heights of candidates who were runners-up. Listed below are heights (in inches) from a few presidential elections.

Heights of winner: 69.5, 73, 73, 74, 74.5, 74.5, 71, 71

Heights of runners-up: 72, 69.5, 70, 68, 74, 74, 73, 76.

  1. What is the correlation between the heights of winning and losing candidates?

  2. Provide p-value for the test H0:ρ=0 vs H1:ρ0 where ρ presents the unknown population correlation of heights of the winners and runners-up.

Proof. (a) Plug-in the formula (6.17) we have r=0.22.

  1. Since we have n=8, using (6.18) we have t=0.221(0.22)282=0.55. Hence, the p-value is 2P(T6<0.55)=0.60.

In your quiz or exam, you can use a simpler way to do the problem by calculate test statistic, reject region or p-value and then make conclusion, ignoring the steps. However, if you are not confident with your answer, please follow those steps, even though you need to write a lot more, you will get more credit if you make some mistake in calculation.