]>
In this section, we will study a number of important hypothesis tests that fall under the general term chi-square tests. These are named, as you might guess, because in each case the test statistics has (in the limit) a chi-square distribution. Although there are several different tests in this general category, they all share some common themes:
Suppose that is a random sample from the Bernoulli distribution with unknown success parameter . Thus, these are independent random variables taking the values 1 and 0 with probabilities and respectively. We want to test versus , where is specified. Of course, we have already studied such tests in the Bernoulli model. But keep in mind that our methods in this section will generalize to a variety of new models that we have not yet studied.
Let and . These statistics give the number of times (frequency) that outcomes 1 and 0 occur, respectively. Moreover, we know that each has a binomial distribution; has parameters and , while has parameters and . In particular, , , and . Moreover, recall that is sufficient for . Thus, any good test statistic should be a function of . Next, recall that when is large, the distribution of is approximately normal, by the central limit theorem. Let Note that is the standard score of under . Hence if is large, has approximately the standard normal distribution under , and therefore has approximately the chi-square distribution with 1 degree of freedom under . As usual, let denote the quantile function of the chi-square distribution with degrees of freedom.
Show that an approximate test of versus at the level of significance is to reject if and only if .
Show that the test in Exercise 1 is equivalent to the unbiased test with test statistic (the approximate normal test) derived in the section on Tests in the Bernoulli model.
For purposes of generalization, the critical result in the next exercise is a special representation of . Let and let . Note that these are the expected frequencies of the outcomes 0 and 1, respectively, under .
Show that
This representation shows that our test statistic measures the discrepancy between the expected frequencies, under , and the observed frequencies. Of course, large values of are evidence in favor of . Finally, note that although there are two terms in the expansion of in Exercise 3, there is only one degree of freedom since . The observed and expected frequencies could be stored in a table.
Suppose now that we have samples from several (possibly) different, independent Bernoulli trials processes. Specifically, suppose that is a random sample of size from the Bernoulli distribution with unknown success parameter for each . Moreover, the samples are independent. We want to test hypotheses about the unknown parameter vector . There are two common cases that we consider below, but first let's set up the essential notation that we will need for both cases. For , and let denote the number of times that outcome occurs in sample . The observed frequency has a binomial distribution; has parameters and while has parameters and .
Consider a given parameter vector . We want to test the null hypothesis , versus . Since the null hypothesis specifies the value of for each , this is called the completely specified case. Now let and let . These are the expected frequencies of the outcomes 0 and 1, respectively, from sample under .
Use Exercise 3 and independence to show that if is large for each , then has approximately the chi-square distribution with degrees of freedom.
As a rule of thumb, large
means that we need
for each
and
. But of course, the larger these expected frequencies the better.
Under the large sample assumption, show that an approximate test of versus at the level of significance is to reject if and only if .
Once again, note that the test statistic measures the discrepancy between the expected and observed frequencies, over all outcomes and all samples. There are terms in the expansion of in Exercise 4, but only degrees of freedom, since for each . The observed and expected frequencies could be stored in a table.
Suppose now that we want to test the null hypothesis that all of the success probabilities are the same, versus the complementary alternative hypothesis that the probabilities are not all the same. Note, in contrast to the previous model, that the null hypothesis does not specify the value of the common success probability . But note also that under the null hypothesis, the samples can be combined to form one large sample of Bernoulli trials with success probability . Thus, a natural approach is to estimate and then define the test statistic that measures the discrepancy between the expected and observed frequencies, just as before. The challenge will be to find the distribution of the test statistic.
Let denote the total sample size when the samples are combined. Then the overall sample mean, which in this context is the overall sample proportion of successes, is The sample proportion is the best estimate of , in just about any sense of the word. Next, let and let . These are the estimated expected frequencies of 0 and 1, respectively, from sample under . Of course these estimated frequencies are now statistics (and hence random) rather than parameters. Just as before, we define our test statistic It turns out that under , the distribution of converges to the chi-square distribution with degrees of freedom as .
Show that an approximate test of versus at the level of significance is to reject if and only if .
Intuitively, we lost a degree of freedom over the completely specified case because we had to estimate the unknown common success probability . Again, the observed and expected frequencies could be stored in a table.
Our next model generalizes the one-sample Bernoulli model in a different direction. Suppose that is a sequence of multinomial trials. Thus, these are independent, identically distributed random variables, each taking values in a set with elements. If we want, we can assume that ; the one-sample Bernoulli model then corresponds to . Let denote the common probability density function of the sample variables on , so that for and . The values of are assumed unknown, but of course we must have , so there are really only unknown parameters. For a given probability density function on we want to test versus
By this time, our general approach should be clear. We let denote the number of times that outcome occurs in sample . Note that has the binomial distribution with parameters and . Thus, is the expected number of times that outcome occurs, under . Out test statistic, of course, is It turns out that under , the distribution of converges to the chi-square distribution with degrees of freedom as . Note that there are terms in the expansion of , but only degrees of freedom since .
Show that an approximate test of versus at the level of significance is to reject if and only if .
Again, as a rule of thumb, we need for each , but the larger the expected frequencies the better.
As you might guess, our final generalization is to the multi-sample multinomial model. Specifically, suppose that is a random sample of size from a distribution on a set with elements, for each . Moreover, we assume that the samples are independent. Again there is no loss in generality if we take . Then reduces to the multi-sample Bernoulli model, and corresponds to the one-sample multinomial model.
Let denote the common probability density function of the variables in sample , so that for , , and . These are generally unknown, so that our vector of parameters is the vector of probability density functions: . Of course, for , so there are actually unknown parameters. We are interested in testing hypotheses about . As in the multi-sample Bernoulli model, there are two common cases that we consider below, but first let's set up the essential notation that we will need for both cases. For and , let denote the number of times that outcome occurs in sample . The observed frequency has a binomial distribution with parameters and .
Consider a given vector of probability density functions on , denoted . We want to test the null hypothesis , versus . Since the null hypothesis specifies the value of for each and , this is called the completely specified case. Let . This is the expected frequency of outcome in sample under .
Use the result from the one-sample multinomial case and independence to show that if is large for each , then has approximately the chi-square distribution with degrees of freedom.
As usual, our rule of thumb is that we need for each and . But of course, the larger these expected frequencies the better.
Under the large sample assumption, show that an approximate test of versus at the level of significance is to reject if and only if .
As always, the test statistic measures the discrepancy between the expected and observed frequencies, over all outcomes and all samples. There are terms in the expansion of in Exercise 8, but we lose degrees of freedom, since for each .
Suppose now that we want to test the null hypothesis that all of the probability density functions are the same, versus the complementary alternative hypothesis that the probability density functions are not all the same. Note, in contrast to the previous model, that the null hypothesis does not specify the value of the common success probability density function . But note also that under the null hypothesis, the samples can be combined to form one large sample of multinomial trials with probability density function . Thus, a natural approach is to estimate the values of and then define the test statistic that measures the discrepancy between the expected and observed frequencies, just as before.
Let denote the total sample size when the samples are combined. Under , our best estimate of is Hence our estimate of the expected frequency of outcome in sample under is . Again, this estimated frequency is now a statistic (and hence random) rather than a parameter. Just as before, we define our test statistic As you no doubt expect by now, it turns out that under , the distribution of converges to a chi-square distribution as . But let's see if we can determine the degrees of freedom heuristically.
Argue that the limiting distribution of has degrees of freedom.
Show that an approximate test of versus at the level of significance is to reject if and only if .
A goodness of fit test is an hypothesis test that an unknown sampling distribution is a particular, specified distribution or belongs to a parametric family of distributions. Such tests are clearly fundamental and important. The one-sample multinomial model leads to a quite general goodness of fit test.
To set the stage, suppose that we have an observable random variable for an experiment, taking values in a general set . Random variable might have a continuous or discrete distribution, and might be single-variable or multi-variable. We want to test the null hypothesis that has a given, completely specified distribution, or that the distribution of belongs to a particular parametric family.
Our first step, in either case, is to sample from the distribution of to obtain a sequence of independent, identically distributed variables . Next, we select and partition into (disjoint) subsets. We will denote the partition by where . Next, we define the sequence of random variables by if and only if for and .
Argue that is a multinomial trials sequence with parameters and , where for .
Let denote the statement that has a given, completely specified distribution. Let denote the probability density function on defined by for . To test hypothesis , we can formally test versus , which of course, is precisely the problem we solved in the one-sample multinomial model.
Generally, we would partition the space into as many subsets as possible, subject to the restriction that the expected frequencies all be at least 5.
Often we don't really want to test whether has a completely specified distribution (such as the normal distribution with mean 5 and variance 9), but rather whether the distribution of belongs to a specified parametric family (such as the normal). A natural course of action in this case would be to estimate the unknown parameters and then proceed just as above. As we have seen before, the expected frequencies would be statistics because they would be based on the estimated parameters. As a rule of thumb, we lose a degree of freedom in the chi-square statistic for each parameter that we estimate, although the precise mathematics can be complicated.
Suppose that we have observable random variables and for an experiment, where takes values in a set with elements, and takes values in a set with elements. Let denote the joint probability density function of , so that for and . Recall that the marginal probability density functions of and are the functions and respectively, where Usually, of course, , , and are unknown. In this section, we are interested in testing whether and are independent, a basic and important test. Formally then we want to test the null hypothesis versus the complementary alternative ,
Our first step, of course, is to draw a random sample from the distribution of . Since the state spaces are finite, this sample forms a sequence of multinomial trials. Thus, with our usual notation, let denote the number of times that occurs in the sample, for each . This statistic has the binomial distribution with trial parameter and success parameter . Under , the success parameter is . However, since we don't know the success parameters, we must estimate them in order to compute the expected frequencies. Our best estimate of is the sample proportion . Thus, our best estimates of and are and , respectively, where is the number of times that occurs in sample and is the number of times that occurs in sample : Thus, our estimate of the expected frequency of under is Of course, we define our test statistic by As you now expect, the distribution of converges to a chi-square distribution as . But let's see if we can determine the appropriate degrees of freedom on heuristic grounds.
Argue that the limiting distribution of has degrees of freedom.
Show that an approximate test of versus at the level of significance is to reject if and only if .
The observed frequencies are often recorded in a table, known as a contingency table, so that is the number in row and column . In this setting, note that is the sum of the frequencies in the row and is the sum of the frequencies in the column. Also, for historical reasons, the random variables and are sometimes called factors and the possible values of the variables categories.
In each of the following exercises, specify the number of degrees of freedom of the chi-square statistic, give the value of the statistic and compute the -value of the test.
Suppose that we have 3 coins. The coins are tossed, yielding the data in the following table:
| Heads | Tails | |
|---|---|---|
| Coin 1 | 29 | 21 |
| Coin 2 | 23 | 17 |
| Coin 3 | 42 | 18 |
A die is tossed 240 times, yielding the data in the following table:
| Score | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| Frequency | 57 | 39 | 28 | 28 | 36 | 52 |
Two dice are tossed, yielding the data in the following table:
| Score | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| Die 1 | 22 | 17 | 22 | 13 | 22 | 24 |
| Die 2 | 44 | 24 | 19 | 19 | 18 | 36 |
The Buffon trial data set gives the results of 104 repititions of Buffon's needle experiment. The number of crack crossings is 56. In theory, this data set should correspond to 104 Bernoulli trials with success probability . Test to see if this is reasonable.
The number of emissions from a piece of radioactive material was recorded for a sample of 100 one-second intervals. The frequency distribution is given in the following table:
| Count | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Frequency | 3 | 1 | 2 | 12 | 23 | 13 | 20 | 9 | 6 | 6 | 4 | 1 |
A university classifies faculty by rank as instructors, assistant professors, associate professors, and full professors. The data, by faculty rank and gender, are given in the following contingency table. Test to see if faculty rank and gender are independent.
| Faculty | Instructor | Assistant Professor | Associate Professor | Full Professor |
|---|---|---|---|---|
| Male | 62 | 238 | 185 | 115 |
| Female | 118 | 122 | 123 | 37 |
Test to see if Michelson's velocity of light data come from a normal distribution.
In the simulation exercises below, you will be able to explore the goodness of fit test empirically.
In the dice goodness of fit experiment, set the sampling distribution to fair, the sample size to 50, and the significance level to 0.1. Set the test distribution as indicated below and in each case, run the simulation 1000 times. In case (a), give the empirical estimate of the significance level of the test and compare with 0.1. In the other cases, give the empirical estimate of the power of the test. Rank the distributions in (b)-(d) in increasing order of apparent power. Do your results seem reasonable?
In the dice goodness of fit experiment, set the sampling distribution to ace-six flats, the sample size to 50, and the significance level to 0.1. Set the test distribution as indicated below and in each case, run the simulation 1000 times. In case (a), give the empirical estimate of the significance level of the test and compare with 0.1. In the other cases, give the empirical estimate of the power of the test. Rank the distributions in (b)-(d) in increasing order of apparent power. Do your results seem reasonable?
In the dice goodness of fit experiment, set the sampling distribution to the symmetric, unimodal distribution, the sample size to 50, and the significance level to 0.1. Set the test distribution as indicated below and in each case, run the simulation 1000 times. In case (a), give the empirical estimate of the significance level of the test and compare with 0.1. In the other cases, give the empirical estimate of the power of the test. Rank the distributions in (b)-(d) in increasing order of apparent power. Do your results seem reasonable?
In the dice goodness of fit experiment, set the sampling distribution to the distribution skewed right, the sample size to 50, and the significance level to 0.1. Set the test distribution as indicated below and in each case, run the simulation 1000 times. In case (a), give the empirical estimate of the significance level of the test and compare with 0.1. In the other cases, give the empirical estimate of the power of the test. Rank the distributions in (b)-(d) in increasing order of apparent power. Do your results seem reasonable?
Suppose that and are different distributions. Is the power of the test with sampling distribution and test distribution the same as the power of the test with sampling distribution and test distribution ? Make a conjecture based on your results in Exercises 24-26.
In the dice goodness of fit experiment, set the sampling and test distributions to fair and the significance level to 0.05. Run the experiment 1000 times for each of the following sample sizes. In each case, give the empirical estimate of the significance level and compare with 0.05.
In the dice goodness of fit experiment, set the sampling distribution to fair, the test distributions to ace-six flats, and the significance level to 0.05. Run the experiment 1000 times for each of the following sample sizes. In each case, give the empirical estimate of the power of the test. Do the powers seem to be converging?