Docsity

K- Sample Methods, The F Statistics - Notes | MATH 324, Study notes of Applied Statistics

Toggle sidebar
bg1
Chapter 3 K-Sample Methods January 8, 2009 1
3K-Sample Methods
∗In the previous chapter we considered just two populations.
∗In the previous chapter we considered just two populations.
∗Now we consider k, an arbitrary number of populations.
∗Now we consider k, an arbitrary number of populations.
General hypothesis test:
H0:F1(x) = F2(x) = ...=Fk(x)
Ha:Fi(x)≤Fj(x) or Fi(x)≥Fj(x)
with strict inequality holding for at least one xand at least one pair (i, j ).
Special case: The populations in Hamight differ only by location; i.e.,
Ha:Fi(x) = F(x−µi)
In this special case of Ha, we may write
Xij =µi+εij,
where Xij is the jth observation for the ith treatment, and the εijs are independent
and have the same distribution.
∗Note that µidoes not need to be a mean.
∗Note that µidoes not need to be a mean.
∗For example, µimight represent the median of a Cauchy distribution, if the εij have
population median zero.
∗For example, µimight represent the median of a Cauchy distribution, if the εij have
population median zero.
∗Goal: Test whether or not these µiare equal.
∗Goal: Test whether or not these µiare equal.
∗Special case: When k= 2 and the εij are independent N(0, σ), we test for equality of
means using the pooled t-test.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download K- Sample Methods, The F Statistics - Notes | MATH 324 and more Study notes Applied Statistics in PDF only on Docsity!

Chapter 3 K-Sample Methods January 8, 2009 1

3 K-Sample Methods

∗ In the previous chapter we considered just two populations. ∗ In the previous chapter we considered just two populations. ∗ Now we consider k, an arbitrary number of populations. ∗ Now we consider k, an arbitrary number of populations. General hypothesis test: H 0 : F 1 (x) = F 2 (x) =... = Fk(x) Ha : Fi(x) ≤ Fj (x) or Fi(x) ≥ Fj (x) with strict inequality holding for at least one x and at least one pair (i, j).

Special case: The populations in Ha might differ only by location; i.e., Ha : Fi(x) = F (x − μi) In this special case of Ha, we may write

Xij = μi + εij ,

where Xij is the jth observation for the ith treatment, and the εij s are independent and have the same distribution. ∗ Note that μi does not need to be a mean. ∗ Note that μi does not need to be a mean. ∗ For example, μi might represent the median of a Cauchy distribution, if the εij have population median zero. ∗ For example, μi might represent the median of a Cauchy distribution, if the εij have population median zero.

∗ Goal: Test whether or not these μi are equal. ∗ Goal: Test whether or not these μi are equal. ∗ Special case: When k = 2 and the εij are independent N(0, σ), we test for equality of means using the pooled t-test.

Section 3.1.1 The F Statistic January 8, 2009 2

∗ Special case: When k = 2 and the εij are independent N(0, σ), we test for equality of means using the pooled t-test. ∗ Special case: When k = 2 and the εij are independent but have heavy tails, we might use a Wilcoxon rank-sum test. ∗ Special case: When k = 2 and the εij are independent but have heavy tails, we might use a Wilcoxon rank-sum test.

3.1.1 The F Statistic

Suppose k ≥ 2 and the εij are independent N(0, σ). We test for equality of means using an F -statistic, via one-way analysis of variance (ANOVA, from Math 321). ∗ The ANOVA F -test is parametric, since normality is assumed. ∗ The ANOVA F -test is parametric, since normality is assumed.

Let X¯ be the overall mean. Let X¯i, si, and ni be the sample mean, sample standard deviation, and sample size, respectively, for the ith population, for i = 1,... , k. Define the F -test statistic by:

F =

∑k ∑i=1k^ ni( X¯i^ −^ X¯)^2 i=1(ni^ −^ 1)s^2 i

(need not memorize).

Under H 0 , the F -statistic has an F -distribution with (k − 1) degrees of freedom for the numerator and (N − k) degrees of freedom for the denominator, where N is the total sample size. Regarding power, do we prefer degrees of freedom to be large or small? ∗ For large power, we want large N but small k, so we prefer that the numerator degrees of freedom be small, and the denominator degrees of freedom be large. ∗ For large power, we want large N but small k, so we prefer that the numerator degrees of freedom be small, and the denominator degrees of freedom be large.

Section 3.1.1 The F Statistic January 8, 2009 4

(a) Graph the data, and explain which crop, corn or tobacco, seems to be more influenced by the brand of fertilizer. Intuitively argue which crop should have the larger value of F.

Fertilizer Corn yield Tobacco yield 1 26 25 1 23 15 1 24 33 1 28 52 2 14 35 2 13 17 2 15 23 2 12 49 3 39 28 3 37 19 3 38 50 3 35 37

> z = scan2( “problem3.1.1”, T, T ) > fertilizer = z[ , 1 ] > corn = z[ , 2 ] > tobacco = z[ , 3 ] > plot( fertilizer, corn ) > plot( fertilizer, tobacco ) ∗ The variability across corn means is large compared to the variability within the corn groups, so F should be large, indicating strong evidence that the mean yields of corn are significantly different (i.e., reject H 0 in favor of Ha). ∗ The variability across corn means is large compared to the variability within the corn groups, so F should be large, indicating strong evidence that the mean yields of corn are significantly different (i.e., reject H 0 in favor of Ha).

Section 3.1.1 The F Statistic January 8, 2009 5

∗ The variability across tobacco means is small compared to the variability within the tobacco groups, so F should be small, lacking strong evidence that the mean yields of tobacco are significantly different (i.e., fail to reject H 0 ). ∗ The variability across tobacco means is small compared to the variability within the tobacco groups, so F should be small, lacking strong evidence that the mean yields of tobacco are significantly different (i.e., fail to reject H 0 ). (b) How many degrees of freedom are associated with each test? ∗ k = 3 populations, and sample size is N = 12. ∗ k = 3 populations, and sample size is N = 12. ∗ k − 1 = 3 − 1 = 2 degrees of freedom for the numerator ∗ k − 1 = 3 − 1 = 2 degrees of freedom for the numerator ∗ N − k = 12 − 3 = 9 degrees of freedom for the denominator ∗ N − k = 12 − 3 = 9 degrees of freedom for the denominator (c) Assume independent and identically distributed normal errors εij in the model: Xij = μi + εij , j = 1,... , ni; i = 1, 2 , 3.

Test if the mean corn yield is the same for all three brands of fertilizer versus the alternative that at least two of the mean corn yields are different. ∗ Let μ 1 , μ 2 , and μ 3 denote the mean corn yields for the three brands of fertilizer. ∗ Let μ 1 , μ 2 , and μ 3 denote the mean corn yields for the three brands of fertilizer. ∗ H 0 : μ 1 = μ 2 = μ 3 versus Ha : At least two of (μ 1 , μ 2 , μ 3 ) are different. ∗ H 0 : μ 1 = μ 2 = μ 3 versus Ha : At least two of (μ 1 , μ 2 , μ 3 ) are different. > perm.f.test( corn, fertilizer, 0 ) ∗ d.f. are 2 and 9, F = 178.13, p-value = 5.786e−8 = 0.00000005786, so reject H 0. ∗ d.f. are 2 and 9, F = 178.13, p-value = 5.786e−8 = 0.00000005786, so reject H 0. ∗ > plot.dist( “df”, 2, 9 ) ∗ > plot.dist( “df”, 2, 9 ) ∗ > shade.dist( 178.13, “df”, 2, 9, F )

Section 3.1.2 Steps in Carrying Out the Permutation F Statistic January 8, 2009 7

∗ Yes, due to the Central Limit Theorem. “Fortunately, procedures for comparing means are not very sensitive to lack of normality. The ANOVA F -test, like the t-procedures, is robust. What matters is normality of the sample means, so ANOVA becomes safer as the sample sizes [of all treatments] get larger, because of the central limit theorem effect” (David S. Moore, 2000, The Basic Practice of Statistics, 2nd edition, pp. 511-512).

3.1.2 Steps in Carrying Out the Permutation

F Statistic

For a permutation F -test, we use the same F -statistic, but we do not approximate the distribution of the F -statistic by an F -distribution. Instead, p-values are based on the permutation distribution of the F -statistic. To obtain this p-value: ⊙ Compute the value of F based on the original data. ⊙ Permute the treatments (or responses) to obtain a permuted F -statistic. ⊙ The observed F -statistic is compared to the values of the F -statistic under either all permutations or a large number of simulated permutations. ⊙ The p-value is the proportion of permuted F -statistics which are at least as large as the observed F -statistic. ∗ Recall that this p-value is based on the right tail only, since a large value of the observed F -statistic supports the alternative hypothesis. ∗ Recall that this p-value is based on the right tail only, since a large value of the observed F -statistic supports the alternative hypothesis.

How many groupings of the treatments are possible (for the sake of obtaining the exact p-value from the permutation F -test)? ∗ N! / (n 1! n 2! · · · nk!)

Section 3.1.2 Steps in Carrying Out the Permutation F Statistic January 8, 2009 8

∗ N! / (n 1! n 2! · · · nk!) ∗ Recall the special case with k = 2. Then, the number of groupings is

(N 1 n 1

)

N!/[n 1! (N − n 1 )!] = N!/(n 1! n 2 !). ∗ Recall the special case with k = 2. Then, the number of groupings is

(N 1 n 1

)

N!/[n 1! (N − n 1 )!] = N!/(n 1! n 2 !). ∗ Recall the example with n 1 = n 2 = 4. ∗ Recall the example with n 1 = n 2 = 4.

Revisit Problem 3.1.1 (corn and tobacco): However, this time, do NOT

assume that the three populations for crop yield are approximately normal. ∗ Since sample sizes are small and normality is not assumed, we will approximate the distribution of the F -statistic using the permutation distribution of the F -test rather than the F -distribution. ∗ Since sample sizes are small and normality is not assumed, we will approximate the distribution of the F -statistic using the permutation distribution of the F -test rather than the F -distribution. How many groupings of the treatments are possible (for the sake of obtaining the exact p-value from the permutation F -test)? ∗ N! / (n 1! n 2! n 3 !) = 12!/(4! 4! 4!) ∗ N! / (n 1! n 2! n 3 !) = 12!/(4! 4! 4!) ∗ factorial(12) / factorial(4)ˆ3 # Answer is 34,650. ∗ factorial(12) / factorial(4)ˆ3 # Answer is 34,650. ∗ The macro ‘perm.f.test’ computes only approximate p-values, based on simulations. ∗ The macro ‘perm.f.test’ computes only approximate p-values, based on simulations. (a) Test if the mean corn yield is the same for all three brands of fertilizer versus the alternative that at least two of the mean corn yields are different.

∗ > z = scan2( “problem3.1.1”, T, T ) ∗ > z = scan2( “problem3.1.1”, T, T )

Section 3.1.2 Steps in Carrying Out the Permutation F Statistic January 8, 2009 10

∗ Here, the μis represent mean tobacco yields rather than mean corn yields. ∗ > perm.f.test( tobacco, fertilizer ) ∗ > perm.f.test( tobacco, fertilizer ) ∗ Note that the p-value based on the ANOVA F -test is 0.9641, as we saw previously. ∗ Note that the p-value based on the ANOVA F -test is 0.9641, as we saw previously. ∗ The permutation p-value should be about 0.963. ∗ The permutation p-value should be about 0.963. 2

F , Chi-square and normal distributions

∗ Here, we show that the limiting value of an F random variable can be χ^2 , and the limiting value of a χ^2 random variable can be normal. ∗ Here, we show that the limiting value of an F random variable can be χ^2 , and the limiting value of a χ^2 random variable can be normal. Plot the χ^21 , χ^22 and χ^23 probability density functions. ∗ The subscripts refer to degrees of freedom. ∗ The subscripts refer to degrees of freedom. ∗ > plot.dist( “dchisq”, 1, NULL, “dchisq”, 2, NULL, “dchisq”, 3 ) ∗ > plot.dist( “dchisq”, 1, NULL, “dchisq”, 2, NULL, “dchisq”, 3 ) ∗ A χ^2 random variable is nonnegative. ∗ A χ^2 random variable is nonnegative. Plot the χ^24 , χ^25 and χ^26 probability density functions. ∗ > plot.dist( “dchisq”, 4, NULL, “dchisq”, 5, NULL, “dchisq”, 6 ) ∗ > plot.dist( “dchisq”, 4, NULL, “dchisq”, 5, NULL, “dchisq”, 6 ) Plot the χ^210 , χ^220 and χ^230 probability density functions. ∗ > plot.dist( “dchisq”, 10, NULL, “dchisq”, 20, NULL, “dchisq”, 30 )

Section 3.1.2 Steps in Carrying Out the Permutation F Statistic January 8, 2009 11

∗ > plot.dist( “dchisq”, 10, NULL, “dchisq”, 20, NULL, “dchisq”, 30 ) For large degrees of freedom, what distribution does a χ^2 distribution approximate? ∗ Normal(ν,

2 ν), where ν is the number of degrees of freedom ∗ Normal(ν,

2 ν), where ν is the number of degrees of freedom ∗ > plot.dist( “dnorm”, 30, sqrt(60), “dchisq”, 30 ) ∗ > plot.dist( “dnorm”, 30, sqrt(60), “dchisq”, 30 )

Recall that the ANOVA F-test has (k − 1) degrees of freedom for the numerator and (N − k) degrees of freedom for the denominator, where k is the number of treatments and N is the sample size. Consider k = 2 treatments and sample sizes of N = 3 or N = 4 or N = 5. Plot the F 1 , 1 , F 1 , 2 and F 1 , 3 probability density functions. ∗ > plot.dist( “df”, 1, 1, “df”, 1, 2, “df”, 1, 3 ) ∗ > plot.dist( “df”, 1, 1, “df”, 1, 2, “df”, 1, 3 ) For fixed k = 2 but large N, what distribution does an F-distribution approximate? ∗ χ^21 ∗ χ^21 ∗ > plot.dist( “dchisq”, 1, NULL, “df”, 1, 3 ) ∗ > plot.dist( “dchisq”, 1, NULL, “df”, 1, 3 ) For any fixed k but large N, what distribution does (k − 1)F approximate, where F has an F-distribution with (k − 1) and (N − k) degrees of freedom? ∗ χ^2 k− 1 ∗ χ^2 k− 1 ∗ Hence, for large sample sizes and fixed k under H 0 , the permutation F -test statistic and ANOVA F -test statistic can be approximated using (not “by”) a χ^2 k− 1 -distribution (and the proportionality constant (k − 1) is needed).

Section 3.2 The Kruskal-Wallis Test January 8, 2009 13

∗ The Kruskal-Wallis p-value is computed the same way as done with the permutation F -test. ∗ The Kruskal-Wallis p-value is computed the same way as done with the permutation F -test. To obtain the Kruskal-Wallis p-value: ⊙ Compute the value of KW based on the original ranks. ⊙ Permute the treatments (or ranks) to obtain a permuted KW-statistic. ⊙ The observed KW-statistic is compared to the values of the KW-statistic under either all permutations or a large number of simulated permutations. ⊙ The p-value is the proportion of permuted KW-statistics at least as large as the observed KW-statistic. ∗ Hence, rejection of H 0 for the Kruskal-Wallis test occurs at the right tail only. ∗ Hence, rejection of H 0 for the Kruskal-Wallis test occurs at the right tail only.

The textbook shows that a strictly monotone increasing relationship exists between the permutation F -statistic based on ranks and the Kruskal-Wallis test statistic. ∗ Therefore, the exact p-value using the exact permutation F -statistic based on ranks is the same as the exact p-value using the KW-statistic. ∗ Therefore, the exact p-value using the exact permutation F -statistic based on ranks is the same as the exact p-value using the KW-statistic. For large sample sizes (with fixed k) under H 0 , the KW-test statistic is approximately χ^2 distributed, with how many degrees of freedom? ∗ k − 1 ∗ k − 1 Is the Kruskal-Wallis test heavily influenced by outliers? ∗ No, since this test is based on ranks. ∗ No, since this test is based on ranks.

Section 3.2 The Kruskal-Wallis Test January 8, 2009 14

Revisit Problem 3.1.1 (corn and tobacco):

(a) Scan in the data, and perform tests based on the TOBACCO data.

> z = scan2( “problem3.1.1”, T, T ) > fertilizer = z[ , 1 ] ∗ > corn = z[ , 2 ] ∗ > corn = z[ , 2 ] > tobacco = z[ , 3 ] ∗ > plot( fertilizer, tobacco ) ∗ > plot( fertilizer, tobacco ) (b) Determine the value of the Kruskal-Wallis test statistic, without using the macro ‘kruskal.test’. ∗ Recall: The Kruskal-Wallis test statistic is:

KW = (^) N(N^12 + 1) ∑^ k i=

ni

( R^ ¯i − N^ + 1 2

) 2 (need not memorize),

where R¯i is the average rank for the ith sample. ∗ Recall: The Kruskal-Wallis test statistic is:

KW = (^) N(N^12 + 1) ∑^ k i=

ni

( R^ ¯i − N^ + 1 2

) 2 (need not memorize),

where R¯i is the average rank for the ith sample. > ranks = rank(tobacco) ∗ [1] 5 1 7 12 8 2 4 10 6 3 11 9 ∗ [1] 5 1 7 12 8 2 4 10 6 3 11 9 > ni = c( 4, 4, 4 ) > N = sum( ni ) ∗ [1] 12 ∗ [1] 12 > mean.rank.i = c( mean(ranks[1:4]), mean(ranks[5:8]), mean(ranks[9:12]) )

Section 3.2 The Kruskal-Wallis Test January 8, 2009 16

∗ > shade.dist( KW, “dchisq”, 2, lower.tail=F ) # Alternatively. ∗ This asymptotic p-value of 0.874052 differs from 0.9641, the p-value from the ANOVA F -test withOUT ranks via ‘> perm.f.test(tobacco, fertilizer, 0)’ (via permuting). ∗ This asymptotic p-value of 0.874052 differs from 0.9641, the p-value from the ANOVA F -test withOUT ranks via ‘> perm.f.test(tobacco, fertilizer, 0)’ (via permuting). ∗ Also, the asymptotic p-value from the chi-square approximation to the KW distribution is NOT the same as the asymptotic p-value from the ANOVA F -test with RANKS (since the latter uses an F approximation rather than a chi-square approximation) via: ∗ Also, the asymptotic p-value from the chi-square approximation to the KW distribution is NOT the same as the asymptotic p-value from the ANOVA F -test with RANKS (since the latter uses an F approximation rather than a chi-square approximation) via: ∗ > perm.f.test(rank(tobacco), fertilizer, 0) ∗ > perm.f.test(rank(tobacco), fertilizer, 0) (f) Obtain the Kruskal-Wallis statistic and p-value using ‘kruskal.test’. > ?kruskal.test ∗ > kruskal.test( tobacco, fertilizer ) ∗ > kruskal.test( tobacco, fertilizer ) ∗ KW is again 0.2692, and p-value is again 0.874, from part (e). ∗ KW is again 0.2692, and p-value is again 0.874, from part (e). 2

∗ Lehmann, 1998, p. 228, for example below. ∗ Lehmann, 1998, p. 228, for example below.

Problem 3.2.1 (Birth conditions and IQ): Steel (1959, Biometrics) pre-

sented the data below for testing whether certain conditions are associated with a lowering of IQ. The IQ score was obtained for 24 girls of which six each are healthy, anoxic, premature, and Rh negative.

Section 3.2 The Kruskal-Wallis Test January 8, 2009 17

∗ {“Anoxic” implies “not enough oxygen.”} ∗ {“Anoxic” implies “not enough oxygen.”}

Healthy 103 111 136 106 122 114 Anoxic 119 100 97 89 112 86 Rh negative 89 132 86 114 114 125 Premature 92 114 86 119 131 94

(a) Graph the data. Intuitively, do the four populations of birth conditions seem to differ regarding IQ?

> IQ = scan2( “problem3.2.1”, F, T ) # Read in data as a vector. > birth.condition = c( rep(1,6), rep(2,6), rep(3,6), rep(4,6) ) ∗ > birth.condition = c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4) ∗ > birth.condition = c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4) > plot( birth.condition, IQ ) ∗ The healthy population appears to be different from the anoxic population, but the variability within each group is large relative to the fact that the sample sizes are small. ∗ The healthy population appears to be different from the anoxic population, but the variability within each group is large relative to the fact that the sample sizes are small. (b) Assume independent and identically distributed errors εij in the model: Xij = μi + εij , j = 1,... , ni; i = 1,... , 4.

∗ It is permissible to mention “means” rather than “medians” if the means are finite. ∗ It is permissible to mention “means” rather than “medians” if the means are finite. Formulate the null and alternative hypotheses for testing if the mean IQ scores are the same for all four types of birth conditions versus the alternative that at least two of the mean IQ scores are different.

Section 3.2 The Kruskal-Wallis Test January 8, 2009 19

∗ p-value is 0. ∗ p-value is 0. ∗ > shade.dist( 0.9601, “df”, 3, 20, F ) # To view the p-value. ∗ > shade.dist( 0.9601, “df”, 3, 20, F ) # To view the p-value. (g) Perform the permutation F -test. ∗ > perm.f.test( IQ, birth.condition ) ∗ > perm.f.test( IQ, birth.condition ) ∗ Simulated p-value is approximately 0.43, which is close to the answer from part (f), noting there are no outliers. ∗ Simulated p-value is approximately 0.43, which is close to the answer from part (f), noting there are no outliers. ∗ The result from part (f) is contained in this result. ∗ The result from part (f) is contained in this result. (h) For which test(s), Kruskal-Wallis test, ANOVA F -test, or permutation F -test, is the assumption of normal errors εij least relevant? ∗ The Kruskal-Wallis test, since outliers do not have huge impacts on ranks, but the two F -tests are a function of means and standard deviations. ∗ The Kruskal-Wallis test, since outliers do not have huge impacts on ranks, but the two F -tests are a function of means and standard deviations. 2