• • • Most often, the comparison of interest is the difference μ1 − μ2. Let μ1 and μ2 denote means two populations. In many situations one wishes to compare the means of two different populations. INFERENCES ABOUT μ1 - μ2 • 1 where σ12 and σ22 are the variances of each of each population. σȲ1−Ȳ2 = The mean of the random variable Ȳ1 − Ȳ2 is μ1 − μ2 and standard deviation is σ12 σ22 + n1 n2 We will make the comparison based on a random sample from each population. Suppose samples of sizes n1 and n2 are drawn. • • σ2 σ2 + =σ n1 n2 1 1 + n1 n2 However, under the assumption that σ12 = σ22 ≡ σ 2, the standard deviation becomes σȲ1−Ȳ2 = 3 • • • For large sample sizes, the random variables Ȳ1 and Ȳ2 are approximately normal . Also assume that the samples are drawn independently from each population, and that the populations have the same variance σ 2. Let Ȳ1 and Ȳ2 denote sample mean random variables and S1 and S2 be the sample standard deviation random variables computed from each sample. 2 Thus the random variable Ȳ1 − Ȳ2 is also approximately normal. An estimator of σȲ1−Ȳ2 is • • • Sp2 is the pooled estimator of the common variance σ 2 of the two populations. 1 1 + n1 n2 • This is obtained under the assumption that σ12 = σ22 ≡ σ 2, the common variance . SȲ1−Ȳ2 = Sp • Later we will talk about what to do if we can’t reasonably make this assumption in a given situation. 4 • Consider the random variable defined as: (Ȳ1 − Ȳ2) − (μ1 − μ2) SȲ1−Ȳ2 • When sampling is from Normal distributions, the distribution of the above statistic is distributed exactly as Student’s t with df = n1 + n2 − 2. Tn1+n2−2 = • n 1 1 = (Y1j − Ȳ1)2 n1 − 1 j=1 S22 n 5 1 1 = (Y2j − Ȳ2)2 n2 − 1 j=1 1 1 + n1 n2 (n1 − 1)s12 + (n2 − 1)s22 n1 + n 2 − 2 Here df = n1 + n2 − 2 and ȳ1 − ȳ2 ± tα/2,df · sp Thus a 100(1-α)% Confidence Interval for μ1 − μ2 is S12 Here S12 and S22 are sample variance random variables . For small samples, however, we must verify if the samples For large samples we may use the CLT and say that Tn1+n2−2 will be approximately distributed as Student’s t with df = n1 + n 2 − 2 • • • • sp = 7 were actually drawn from Normal distributions, using tools such as boxplots and normal probability plots • We shall do that before calculating confidence intervals for μ1 − μ2, and for testing hypotheses using the t distribution. − 1)S12 + (n2 − 1)S22 n1 + n 2 − 2 • (n1 6 The pooled estimator of the common variance σ 2, Sp2, is obtained using the weighted average Sp2 = Example 6.1 Stored 9.8 9.7 9.6 9.5 10.1 9.6 10.2 9.8 10.1 9.9 Company officials, concernerned about potency of a product retained after storage, drew a random sample of n1 = 10 bottles from the production line and tested for potency. Another random sample of n2 = 10 bottles was drawn and stored in a regulated environment for 1 year and then tested. The data obtained are: Fresh 10.2 10.6 10.5 10.7 10.3 10.2 10.8 10.0 9.8 10.6 8 n1 = 10 ȳ1 = 103.7/10 = 10.37 2 n2 = 10 2 9 2 (s + s22) 18 1 ȳ2 = 98.3/10 = 9.83 ]/9 = 0.105 s12 = [1076.31 − (103.7) 10 (n1 − 1)s12 + (n2 − 1)s22 = n1 + n 2 − 2 s22 = [966.81 − (98.3) 10 ]/9 = .058 sp = = .105 + .058 = 0.285 2 9 11 1 10 1 + 10 The t-percentile based on df = n1 +n2 −2 = 10+10−2 = 18 and α = .025 is t.025,18 = 2.101 Thus a 95% confidence interval for the difference in the mean potencies μ1 − μ2 is: (10.37 − 9.83) ± 2.102(.285) 10 .54 ± .268 or (.272, .808) Thus, the difference in mean potencies for bottles from the production line and those stored for one year, μ1 − μ2, is estimated to be between .272 and .808 with 95% confidence. It is important understand what we mean by the above statement; this will be explained soon. See the JMP Analysis of Example 6.1 also. Tests of Hypotheses about μ1 − μ2 The types of hypothesis that may be tested are similar to those on the mean of a single population. These are: 1. H0 : μ1 − μ2 ≤ D0 Ha : μ1 − μ2 > D0 2. H0 : μ1 − μ2 ≥ D0 Ha : μ1 − μ2 < D0 3. H0 : μ1 − μ2 = D0 Ha : μ1 − μ2 = D0 (where D0 is a specified number, often zero.) 1 n1 + n12 Ȳ1 − Ȳ2 − D0 The test statistic for testing each of the above hypotheses is T = Sp 12 1 n1 + n12 ȳ1 − ȳ2 − D0 The two-sample t-statistic is calculated using the sample statistics: ȳ1, ȳ2 and sp: t= sp The rejection regions for each test, respectively, are: 1. Reject H0 if t > tα, df 2. Reject H0 if t < −tα, df 3. Reject H0 if |t| > tα/2, df 13 Note that the degrees of freedom is df = n1 + n2 − 2 Exercise 6.8 Two different emission-control devices were being tested to determine the average amount of nitric oxide being emitted by an automobile over a 1-hour period of time. Twenty cars of the same model and year were selected for the study. Ten cars were randomly selected and equipped with a Type 1 emission-control device, and the remaining cars were equipped with Type II devices. Each of the 20 cars was then monitored for a 1-hour period to determine the amount of nitric oxide emitted. Type II Device 1.01 0.96 0.98 0.99 0.95 0.98 1.02 1.01 1.05 1.02 Use the following data to test the research hypothesis that the mean level of emission for Type 1 devices (μ1) is greater than the mean emission level for Type II devices (μ2). Use α = .01. Type 1 Device 1.35 1.28 1.16 1.21 1.23 1.25 1.20 1.17 1.32 1.19 15 Refer to Example 6.3: JMP Analysis also ȳ2 = 0.997 n1 = n2 = 10 ȳ1 = 1.236 9 2 18 (s1 + s22) = 0.0025 s12 = 0.004096 s22 = 0.0009 sp2 = 1.236−0.997 √ 0.05 0.2 = 10.71 sp = 0.05 H0 : μ1 − μ2 ≤ 0 vs. Ha : μ1 − μ2 > 0 tc = t0.01,18 = 2.552 implying R.R. is t > 2.552 Therefore reject H0 at α = .01 as tc is in the R.R. 14 Thus it appears that the mean level of emission for the Type I device is greater than for Type II. 16 • • • The above confidence interval and test formulae are based on several assumptions The two samples are drawn independently from the two populations. The two populations are such that Ȳ1 and Ȳ2 are approximately normal. (We make use of the CLT if the size of samples n1 and n2 are sufficiently large.) The two populations have the same variance σ 2 (in order to see if this assumption may not hold one looks at s12 and s22.) 17 Assumption 3. is the unusual one based on our previous discussions. When n1 = n2 = n, unless studies indicate that Welch’s t test The hypotheses to be tested are as usual: (ȳ1 − ȳ2) − D0 + n22 s2 1. H0 : μ1 − μ2 ≤ D0 Ha : μ1 − μ2 > D0 2. H0 : μ1 − μ2 ≥ D0 Ha : μ1 − μ2 < D0 3. H0 : μ1 − μ2 = D0 Ha : μ1 − μ2 = D0 The test statistic is : t = s12 n1 Note that the two sample variances are NOT pooled to obtain a pooled sample variance estimate. 19 σ12 and σ22 can differ by as much as a factor of 3, it won’t make a difference in the inference about μ1 − μ2 based on the use of given formulae for C.I.’s and tests. When we find ourselves in a situation where Assumption 3. seems to be seriously violated, we can use an an approximate t test described below. 18 Assumption 1. requires that the samples from the two populations are obtained in such a way that the elements of the two samples are statistically independent. Read page 274 of the text for a detailed discussion of examples of dependencies that may occur due to experimental conditions. df = (round down to an integer) (n1 − 1)(n2 − 1) (n2 − 1)c2 + (1 − c)2(n1 − 1) The percentile points of the t-statistic are approximated by using the t-table with an adjusted degrees of freedom given by: where c= s2/n1 1 s12 s22 n1 + n2 20 Welch’s t test (continued) For specified α the rejection regions for the three hypotheses, respectively, are given by: 1. Reject H0 if t > tα, df 2. Reject H0 if t < −tα, df 3. Reject H0 if |t| > tα/2, df Oil Spill Case Study from Section 6.1 We shall follow the analysis in the text book fof this study. The following two pages are reproduced from the text book. 22 Also, refer to the Oil Spill Case Study: JMP Analysis handed out. 21 24 An approximate 100(1 − α)% confidence interval for μ1 − μ2 is: s12 s22 + (ȳ1 − ȳ2) ± tα/2, df · n1 n2 where tα/2 is the t quantile found from the t-table for df computed using the above formula. 23 • • • Inferences about μ1 − μ2 for Paired Data (μ2, σ22), Consider independent samples from two populations having means and variances and respectively. (μ1, σ12) The mean and variance of the sampling random variable Ȳ1 − Ȳ2 are: E(Ȳ1 − Ȳ2) = μ1 − μ2 σ2 σ2 V (Ȳ1 − Ȳ2) = 1 + 2 n1 n2 s12 s2 + 2 . n1 n2 Point estimates of these we know are: and • • • σ22 1 1 + n1 n2 If the two populations have the same variances, so that = = σ 2 then σ12 V (Ȳ1 − Ȳ2) = σ 2 s12+s22 2 (n1 − 1)s12 + (n2 − 1)s22 n1 + n 2 − 2 Then we estimate σ 2 by pooling the two sample estimates of σ 2 as sp2 = If n1 = n2 = n then sp2 = • Instead of using independent samples from the two populations, we form pairs of elements – one element from each population, in an effort to achieve smaller variance for Ȳ1 − Ȳ2 ȳ1 − ȳ2 Why variance is reduced by pairing data? • Then the random sample of n pairs of elements can be viewed as having come from a population of pairs. 26 • In either case, what this means is that if the variances of the two populations is small , we can expect the variance of Ȳ1 − Ȳ2 to be small. • 25 • If this is true, we can expect the sample values to be close to the sample means and ȳ1 − ȳ2 to be very close to μ1 − μ2. The random variable representing the difference in sample means Ȳ1 − Ȳ2 defined on this population has σ 2 σ 2 2σ12 1 + 2− n n n • V (Ȳ1 − Ȳ2) = Thus even a small sample will be sufficient to get a good estimate of μ1 − μ2 if the variances are small. E(Ȳ1 − Ȳ2) = μ1 − μ2 • 28 But many times the population variances σ 2 are large, so that we cannot estimate μ1 − μ2 accurately with a small sample. 27 • • The quantity σ12 is called the covariance of the two populations. σ22 n We see from the variance of Ȳ1 − Ȳ2 that if σ12 > 0 then V − is less than + σ12 n • That is, the variance of Ȳ1 − Ȳ2 for paired data is less than it is for two independent samples, each of sample size n. Ȳ2) • Thus we expect the differences of means for paired data to have a smaller variance than when the difference of means is from two independent samples. (Ȳ1 • For this to occur we need to pair the elements so that the covariance of the observed data is positive. That is, the two samples are positively correlated . • • • Those methods cannot be used when each measurement in one sample is somehow matched or paired with a particular measurement in the other sample. So far we looked at methods for hypothesis tests and confidence intervals when independent samples were taken from the two populations. If pairing is done so that paired elements respond more alike when μ1 = μ2 than do two randomly selected elements (one from each population), then σ12 > 0, i.e, we will have achieved our goal of smaller variance when estimating μ1 −μ2 30 Example 6.6 in your textbook where 15 wrecked cars were taken to each of two garages to get an estimate of the cost of repair. The study was to see if the two facilities gave different average estimates. Independent samples of estimates would not have involved the same wrecked cars. That is, to get 2 independent samples of sample size 15, we would have to take 30 wrecks to the 2 garages. The variance of estimates for repairs would be large because of the types of repair involved would be very different for each car. • Suppose a consumer testing organization wants to study whether there is a difference in the wear rates of two brands of work shoes. (a) Suppose that workers selected for the experiment were divided into two groups randomly. Members of one group were assigned to wear Brand X to work while the members of the other group wear Brand Y shoes. (b) Population 1 consists of the wear rates for persons assigned Brand X with the mean wear rate μ1, and Population 2, wear rates for those assigned Brand Y with the mean wear rate μ2. (c) We are interested in estimating μ1 − μ2 and trying to test whether μ1 − μ2 = 0. 29 • Studies of response to a treatment vs. a control are often done using siblings, or sometimes the same individual. 32 Examples: Paired Experiments • 31 • • Independent Samples Kind of Study:(2 groups of size n) Take a random sample of workers, randomly divide them into two groups, one to receive each Brand, and measure the wear rate for each person after 100 workdays. Then ȳ1 − ȳ2 estimates μ1 − μ2. 33 A Paired Data Kind of Study:(1 group of size n) Take a random sample of workers. Assign Brand X to all workers in the group and measure the wear rates following 100 workdays. Now assign the same workers Brand Y and measure wear rate after the next 100 workdays. ȳ1 − ȳ2 estimates μ1 − μ2. • • • • Thus the variance of ȳ1 − ȳ2 is inflated by the variance among the workers. For the paired data case, differences in changes are also computed and averaged as above. However, the worker is the same in each pairs so in taking the difference we have eliminated any effect due to each worker. Members of a pair are selected so they respond more alike than two arbitrarily selected individuals if the treatment had no effect. This reduces variation in the differences in response, hence it allows us to better detect differences between μ1 and μ2. 35 • • • • • Why is variance less for paired data? Brand Y y21 y22 y23 . y2n ȳ2 y1n − y2n ȳ1 − ȳ2 Difference in Wear y11 − y21 y12 − y22 . Consider data from the independent samples experiment: Brand X y11 y12 y13 . y1n ȳ1 34 Note carefully that the difference ȳ1 − ȳ2. rates also include differences in the workers (weight, kind of work, walking habits etc.) who wore those particular shoes. Paired t test for n pairs of data di2 − Suppose μd ≡ μ1 − μ2 denote the mean of the population of differences. Denote the differences in pairs of observations by di = y1i − y2i d¯ = ( di)/n be the sample mean of the differences of pairs of data. s be standard deviation of the differences of pairs of data d where ( di)2 /(n − 1) n sd2 = 36 : Tests of Hypotheses about μd μd ≤ D0 vs. Ha : μd > D0 The types of hypothesis that may be tested are similar to those on the mean of a single population. These are: 1. H0 2. H0 : μd ≥ D0 vs. Ha : μd < D0 3. H0 : μd = D0 vs. Ha : μd = D0 d¯ − D0 √ sd/ n The test statistic for testing each of the above hypotheses is the paired t-statistic: t= Choosing Type I error rate to be α, the rejection regions are, respectively, 1. Reject if: t > tα,(n−1) 2. Reject if: t < −tα,(n−1) 3. Reject if: |t| > tα/2,(n−1) Confidence Interval for μd A 100(1 − α)% confidence interval for μd is: √ d¯ ± tα/2 · sd / n where tα/2 is the tabulated t percentile based on n − 1 df. • A 99% confidence interval for μd is: √ d¯ ± t.005 · sd / n = 0.66 ± (3.25)(0.1701) giving (.10, 1.21) 40 • The p-value is obtained by looking up Table 2 with tc = 3.88 with df = 9. It is seen that .001 < p < 0.005 Since t.005,9 = 3.25, R.R. is |t| > 3.25; Reject H0 : at α = .01. The paired t-statistic is: √ ¯ d/ 10) = .66/0.1701 = 3.88 tc = d/(s 38 d2 0.49 0.64 1.69 0.04 0.16 0.64 0.04 2.89 0.01 0.36 di2 = 6.96 37 d = R1 − R2 0.7 0.8 1.3 0.2 0.4 0.8 0.2 1.7 -0.1 0.6 di = 6.6 • Let μd = μ1 − μ2 where μ1 and μ2 are the population means for the two rations. • Test H0 : μd = 0 vs. Ha : μd = 0 using α = .01 2 sd2 = [ di2 − ( ndi) ]/(n − 1) = (6.96 − 6.62/10)/9 = 0.2893 R2 9.9 10.2 9.3 9.6 8.8 7.8 6.4 8.3 8.0 7.8 Example: Pairs are animals from the same litter are randomly assigned two different rations. Observed weight gain for each animal is recorded. Test whether the population mean weight gains for the two rations are different. Use α = .01. R1 10.6 11.0 10.6 9.8 9.2 8.6 6.6 10.0 7.9 8.4 39 1 48.2 41.5 6.7 2 44.6 40.1 4.5 3 49.7 44.0 5.7 4 40.5 41.2 -0.7 5 54.6 49.8 4.8 6 47.1 41.7 5.4 7 51.4 46.8 4.6 41 Exercise 6.28: An agricultural experiment station was interested in comparing the yields for two new varieties of corn. Because the investigators thought that there might be a great deal of variability in yield from one farm to another, each variety was randomly assigned to a different 1-acre plot on each of seven farms. The 1-acre plots were planted; the corn was harvested at maturity. The results of the experiment (in bushels of corn) are listed here. Farm Variety A Variety B Difference Use these data to test the null hypothesis that there is no difference in mean yields for the two varieties of corn. Use α = .05. 43 Refer to Example 6.6 : JMP Analysis Test H0 : μd = 0 vs. Ha : μd = 0 = 4.43√ 2.39/ 7 = 4.90 42 Calculate paired t-statistic: d¯ = 4.43 2 2 di −( di) /n]/(n−1) = (171.48−31.02/7)/6 = 5.7 sd2 = [ d¯√ sd / n Thus sd = 2.39 Thus tc = with α = 0.05, df = 6 → tα/2,df = t0.025,6 = 2.447 Thus the R.R. is: |t| > 2.447, So H0 is rejected at α = 0.05 since 4.9 is in R.R. The mean yields of the two varieties are different based on this evidence. 44 Exercise 6.32 A study was designed to measure the effect of home environment on academic achievement of 12-year old students. Because genetic differences may also contribute tp academic achievement, the researcher wanted to control for this factor. Thirty sets of identical twins were identified who had been adopted prior to their first birthday, with one twin placed in a home in which academics were emphasized (Academic) and the other twin placed in a home in which academics were not emphasized (Nonacademic). The final grades (based on 100 points) for the 60 students are given below. a. Plot the sample differences. Do the conditions for using the paired t procedure appear to be satisfied for this data. b. Estimate the size of the difference in the mean final grades of the students in academic and nonacademic home environments. Academic Environment, y1 66 75 90 89 73 61 76 81 89 82 70 68 74 85 97 95 78 Nonacademic Environment, y2 67 70 88 80 65 60 74 76 78 78 62 73 73 75 88 94 75 Difference -1 5 2 9 8 1 2 5 11 4 8 -5 1 10 9 1 3 47 45 c. Examine whether there is a difference in the mean final grade between students in an academically oriented home environment and those in a nonacademic home environment. That is, test the null hypothesis H0 : μ1 − μ2 = 0 against the alternative Ha : μ1 − μ2 = 0. Use α = .05. Also compute the p-value for this test. Set of Twins 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Set of Twins 1 2 3 4 5 6 7 8 9 10 11 12 13 Academic Environment, y1 78 75 68 92 55 74 65 80 98 52 67 55 49 Nonacademic Environment, y2 71 70 66 85 60 72 57 75 92 56 63 52 48 Difference 7 5 2 7 -5 2 8 5 6 -4 4 3 1 Continued on the next page 46 Solution: a). The assumption on which the paired t is based is that the population of differences is approximately normal. To investigate this you look at the sample differences. We need, as always, large n and not severe skewness, or indication of approximate normality of differences. When differences are highly skewed, one may use the nonparametric test. b). d¯ = 3.8 sd = 4.205 Thus a 95% confidence interval for μd is d¯ ± t.025,29 · √sdn √ 3.8 ± 2.045 · 4.205 30 giving (2.23, 5.37) as the required estimate. 48 c). The test statistic is: 3.8−0 √ = 4.95 t = (4.205/ 30 Since t.025,29 = 2.045, R.R. : |t| > 2.045 Reject H0 because tc = 4.95 exceeds 2.045. From t-table, p-value = 2 · P (T29 > 4.95) << 2 · .0001 Since the p-value is less than .005, which is certainly less than .05, we reject H0 at α = .05 Refer to Exercise 6.32 :JMP Analysis 49