Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 12 The Analysis of Categorical Data and Goodness-of-Fit Tests.

Similar presentations


Presentation on theme: "Chapter 12 The Analysis of Categorical Data and Goodness-of-Fit Tests."— Presentation transcript:

1 Chapter 12 The Analysis of Categorical Data and Goodness-of-Fit Tests

2 2 Univariate Categorical Data Univariate categorical data is best summarized in a one-way frequency table. For example, consider the following observations of sample of faculty status for faculty in a large university system.

3 3 Univariate Categorical Data A local newsperson might be interested in testing hypotheses about the proportion of the population that fall in each of the categories. For example, the newsperson might want to test to see if the five categories occur with equal frequency throughout the whole university system. To deal with this type of question we need to establish some notation.

4 4 Notation k = number of categories of a categorical variable  1 = true proportion for category 1  2 = true proportion for category 2   k = true proportion for category k (note:  1 +  2 +  +  k = 1)

5 5 Hypotheses H 0 :  1 = hypothesized proportion for category 1  2 = hypothesized proportion for category 2   k = hypothesized proportion for category k H a :H 0 is not true, so at least one of the true category proportions differs from the corresponding hypothesized value.

6 6 Expected Counts For each category, the expected count for that category is the product of the total number of observations with the hypothesized proportion for that category.

7 7 Expected Counts - Example Consider the sample of faculty from a large university system and recall that the newsperson wanted to test to see if each of the groups occurred with equal frequency.

8 8 Goodness-of-fit statistic,  2

9 9 Chi-square distributions

10 10 Upper-tail Areas for Chi-squared Distributions

11 11 Goodness-of-Fit Test Procedure Hypotheses: H 0 :  1 = hypothesized proportion for category 1  2 = hypothesized proportion for category 2   k = hypothesized proportion for category k H a :H 0 is not true

12 12 Goodness-of-Fit Test Procedure P-values: When H 0 is true and all expected counts are at least 5,  2 has approximately a chi-squared distribution with df = k-1. Therefore, the P-value associated with the computed test statistic value is the area to the right of  2 under the df = k-1 chi-squared curve.

13 13 Goodness-of-Fit Test Procedure Assumptions: 1.Observed cell counts are based on a random sample. 2.The sample size is large. The sample size is large enough for the chi-squared test to be appropriate as long as every expected count is at least 5.

14 14 Example Consider the newsperson’s desire to determine if the faculty of a large university system were equally distributed. Let us test this hypothesis at a significance level of 0.05. Let  1,  2,  3,  4, and  5 denote the proportions of all faculty in this university system that are full professors, associate professors, assistant professors, instructors and adjunct/part time respectively. H 0 :  1 = 0.2,  2 = 0.2,  3 = 0.2,  4 = 0.2,  5 = 0.2 H a : H 0 is not true

15 15 Example Significance level:  = 0.05 Assumptions: As we saw in an earlier slide, the expected counts were all 30.8 which is greater than 5. Although we do not know for sure how the sample was obtained for the purposes of this example, we shall assume selection procedure generated a random sample.

16 16 Example Calculation: recall

17 17 Example P-value: The P-value is based on a chi- squared distribution with df = 5 - 1 =4. The compute value of  2, 7.56 is smaller than 7.77, the lowest value of  2 in the table for df = 4, so that the P- value is greater than 0.100. Conclusion: Since the P-value > 0.05 = , H 0 cannot be rejected. There is not sufficient evidence to refute the claim that the proportion of faculty in each of the different categories is the same.

18 18 Tests for Homogeneity and Independence in a Two-Way Table Data resulting from observations made on two different categorical variables can be summarized using a tabular format. For example, consider the student data set giving information on 79 student dataset that was obtained from a sample of 79 students taking elementary statistics. The table is on the next slide.

19 19 Tests for Homogeneity and Independence in a Two-Way Table This is an example of a two-way frequency table, or contingency table. The numbers in the 6 cells with clear backgrounds are the observed cell counts.

20 20 Tests for Homogeneity and Independence in a Two-Way Table Marginal totals are obtained by adding the observed cell counts in each row and also in each column. The sum of the column marginal total (or the row marginal totals) is called the grand total.

21 21 Tests for Homogeneity in a Two-Way Table Typically, with a two-way table used to test homogeneity, the rows indicate different populations and the columns indicate different categories or vice versa. For a test of homogeneity, the central question is whether the category proportions are the same for all of the populations

22 22 Tests for Homogeneity in a Two-Way Table When the row indicates the population, the expected count for a cell is simply the overall proportion (over all populations) that have the category times the number in the population. To illustrate:

23 23 Tests for Homogeneity in a Two-Way Table The expected values for each cell represent what would be expected if there is no difference between the groups under study can be found easily by using the following formula.

24 24 Tests for Homogeneity in a Two-Way Table

25 25 Tests for Homogeneity in a Two-Way Table Expected counts are in parentheses.

26 26 Comparing Two or More Populations Using the  2 Statistic Hypotheses: H 0 :The true category proportions are the same for all of the populations (homogeneity of populations). H a :The true category proportions are not all the same for all of the populations.

27 27 Comparing Two or More Populations Using the  2 Statistic

28 28 Comparing Two or More Populations Using the  2 Statistic P-value:When H 0 is true,  2 has approximately a chi-squared distribution with df = (number of rows - 1)(number of columns - 1) The P-value associated with the computed test statistic value is the area to the right of c2 under the chi-squared curve with the appropriate df.

29 29 Comparing Two or More Populations Using the  2 Statistic Assumptions: 1.The data consists of independently chosen random samples. 2.The sample size is large: all expected counts are at least 5. If some expected counts are less than 5, rows or columns of the table may be combined to achieve a table with satisfactory expected counts.

30 30 Example The following data come from a clinical trial of a drug regime used in treating a type of cancer, lymphocytic lymphomas.* Patients (273) were randomly divided into two groups, with one group of patients receiving cytoxan plus prednisone (CP) and the other receiving BCNU plus prednisone (BP). The responses to treatment were graded on a qualitative scale. The two-way table summary of the results is on the following slide. * Ezdinli, E., S., Berard, C. W., et al. (1976) Comparison of intensive versus moderate chemotherapy of lympocytic lymphomas: a progress report. Cancer, 38, 1060-1068.

31 31 Example Set up and perform an appropriate hypothesis test at the 0.05 level of significance.

32 32 Hypotheses: H 0 :The true response to treatment proportions are the same for both treatments (homogeneity of populations). H a :The true response to treatment proportions are not all the same for both treatments. Example Significance level:  = 0.05

33 33 Example Assumptions:All expected cell counts are at least 5, and samples were chosen independently so the  2 test is appropriate.

34 34 Example Calculations: The two-way table for this example has 2 rows and 4 columns, so the appropriate df is (2-1)(4-1) = 3. Since 4.60 0.10 >  = 0.05 so H 0 is not rejected. There is not sufficient evidence to conclude that the responses are different for the two treatments.

35 35 Comparing Two or More Populations Using the  2 Statistic P-value:When H 0 is true,  2 has approximately a chi-squared distribution with df = (number of rows - 1)(number of columns - 1)

36 36 Example II The following data come from a study of the length of stay of 336 patients in psychiatric observation ward prior to be sent to another location. The observed variables are length of stay and four categories combining gender and status of admission.

37 37 Example II

38 38 Example III The following data come from a study of Hodgkin's disease, a cancer of the lymph nodes. The observed variables are histological type and response to treatment 3 months after it had begun. LP = lymphocyte dominance NS = Nodular sclerosis MC = mixed cellurarity LD = lymphocyte depletion

39 39 Hypotheses: H 0 :The two variables are independent. H a :The two variables are not independent.  2 Test for Independence The  2 test statistic and procedures can also be used to investigate the association between tow categorical variable in a single population.

40 40  2 Test for Independence

41 41 P-value:When H 0 is true,  2 has approximately a chi-squared distribution with df = (number of rows - 1)(number of columns - 1)  2 Test for Independence

42 42 Assumptions: 1.The observed counts are from a random sample. 2.The sample size is large: all expected counts are at least 5. If some expected counts are less than 5, rows or columns of the table may be combined to achieve a table with satisfactory expected counts.  2 Test for Independence

43 43 Example Consider the two categorical variables, gender and principle form of vision correction for the sample of students used earlier in this presentation. We shall now test to see if the gender and the principle form of vision correction are independent.

44 44 Example Hypotheses: H 0 :Gender and principle method of vision correction are independent. H a : Gender and principle method of vision correction are not independent. Significance level: We have not chosen one, so we shall look at the practical significance level.

45 45 Example Assumptions: We are assuming that the sample of students was randomly chosen. All expected cell counts are at least 5, and samples were chosen independently so the  2 test is appropriate.

46 46 Example Assumptions: Notice that the expected count is less than 5 in the cell corresponding to Female and Contacts. So that we should combine the columns for Contacts and Glasses to get

47 47 Example Calculations: The contingency table for this example has 2 rows and 2 columns, so the appropriate df is (2-1)(2-1) = 1. Since 0.246 < 2.70, the P-value is substantially greater than 0.10. H 0 would not be rejected for any reasonable significance level. There is not sufficient evidence to conclude that the gender and vision correction are related. (I.e., For all practical purposes, one would find it reasonable to assume that gender and need for vision correction are independent.

48 48 Example Minitab would provide the following output if the frequency table was input as shown. Chi-Square Test: Contacts or Glasses, None Expected counts are printed below observed counts Contacts None Total 1 14 11 25 12.97 12.03 2 27 27 54 28.03 25.97 Total 41 38 79 Chi-Sq = 0.081 + 0.087 + 0.038 + 0.040 = 0.246 DF = 1, P-Value = 0.620


Download ppt "Chapter 12 The Analysis of Categorical Data and Goodness-of-Fit Tests."

Similar presentations


Ads by Google