Presentation is loading. Please wait.

Presentation is loading. Please wait.

Goodness-of-Fit Tests and Categorical Data Analysis

Similar presentations


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

1 Goodness-of-Fit Tests and Categorical Data Analysis
14

2 Goodness-of-Fit Tests
Goodness-of-Fit Tests

3 Testing for goodness of fit
We use the chi-square test as the tool to compare two or more distributions all based on sample data. We consider a slight variation on this scenario where only one of the distributions is known (our sample data observations) and we want to compare it with a hypothesized distribution. Data for n observations on a categorical variable with k possible outcomes are summarized as observed counts, n1, n2, , nk. The null hypothesis specifies probabilities p1, p2, , pk for the possible outcomes. In the last two sections 9.1 and 9.2, we discussed the use of the chi square test to compare two categorical variables. We now compare one categorical variable from one population with a hypothesized distribution.

4 Car accidents and day of the week
A study of 667 drivers who were using a cell phone when they were involved in a collision on a weekday examined the relationship between these accidents and the day of the week. Are the accidents equally likely to occur on any day of the working week? H0 specifies that all 5 days are equally likely for car accidents  each pi = 1/5.

5 The chi-square goodness of fit test
Data for n observations on a categorical variable with k possible outcomes are summarized as observed counts, n1, n2, , nk in k cells. H0 specifies probabilities p1, p2, , pk for the possible outcomes. For each cell, multiply the total number of observations n by the specified probability pi: expected count = npi The chi-square statistic follows the chi-square distribution with k − 1 degrees of freedom:

6 Chi-squared distribution
If H0 is true, the chi-square test has approximately a χ2 distribution with degrees of freedom. The c2 distributions are a family of distributions that can take only positive values, are skewed to the right, and are described by a specific degrees of freedom.

7 Finding the p-value with Table A.7.
The P-value for the chi-square test is the area to the right of c2 under the c2 distribution with df P(χ2 ≥ X2). Table A.7 gives upper critical values for many c2 distributions.

8 Table A.7. Ex: 7 possible outcomes (k=7) Then, df = (k−1)=6
If X2 = 16.1, the p-value is between 0.01−0.02.

9 Car accidents and day of the week
H0 specifies that all days are equally likely for car accidents  each pi = 1/5. The expected count for each of the five days is npi = 667(1/5) = Following the chi-square distribution with 5 − 1 = 4 degrees of freedom. The p-value is thus between 0.1 and 0.05, which is not significant at α 5%.  There is no significant evidence of different car accident rates for different weekdays when the driver was using a cell phone.

10 Two-Way Contingency Tables
14.3 Two-Way Contingency Tables

11 Hypothesis: no association
Again, we want to know if the differences in sample proportions are likely to have occurred just by chance due to random sampling. We use the chi-square (c2) test to assess the null hypothesis of no relationship between the two categorical variables of a two-way table.

12 Expected cell counts Two-way tables sort the data according to two categorical variables. We want to test the hypothesis that there is no relationship between these two categorical variables (H0). To test this hypothesis, we compare actual counts from the sample data with expected counts, given the null hypothesis of no relationship. The expected count in any cell of a two-way table when H0 is true is: State the null hypothesis and the alternative hypothesis. To test the null hypothesis, we compare the observed cell counts with expected cell counts calculated under the assumption that the null hypothesis is true.

13 Expected relapse counts
Cocaine addiction Observed Expected Expected relapse counts No Yes 35% 35% 35% (25)(26)/74 ≈ x 0.35 x 0.65 x 0.35 x 0.65 x 0.35 x 0.65 Desipramine Lithium Placebo

14 Successful firms Franchise businesses are sometimes given an exclusive territory by contract. This means that the new outlet will not have to compete with other outlets of the same chain within its own territory. How does the presence of an exclusive-territory clause in the contract relate to the survival of the business? A simple random sample of 170 new franchises recorded two categorical variables for each firm: (1) whether the firm was successful or not (based on economic criteria) and (2) whether or not the firm had an exclusive-territory contract. This is a 2x2 table (two levels for success, yes/no; two levels for exclusive territory, yes/no). df = (2 − 1)(2 − 1) = 1

15 Successful firms Specifically, we will test:
H0: No relationship between exclusive clause and success Ha: There is some relationship between the two variables The p-value is significant at α = 5% (p = 1.5%). Thus, we reject the null hypothesis. We have found a significant relationship between an exclusive territory and the success of a franchised firm.

16 Computations for two-way tables
When analyzing relationships between two categorical variables, follow this procedure: 1. Calculate descriptive statistics that convey the important information in the table—usually column or row percents. 2. Find the expected counts and use them to compute the X2 statistic. 3. Compare your X2 statistic to the chi-square critical values to find the approximate P-value for your test. 4. Draw a conclusion about the association between the row and column variables.

17 Computing expected counts
When testing the null hypothesis that there is no relationship between both categorical variables of a two-way table, we compare actual counts from the sample data with expected counts given H0. The expected count in any cell of a two-way table when H0 is true is: Although in real life counts must be whole numbers, an expected count need not be. The expected count is the mean over many repetitions of the study, assuming no relationship.

18 Music and wine purchase decision
The null hypothesis is that there is no relationship between music and wine sales. The alternative is that these two variables are related. What is the expected count in the upper-left cell of the two-way table, under H0? Column total 84: Number of bottles sold without music Row total 99: Number of bottles of French wine sold Table total 243: all bottles sold during the study This expected cell count is thus (84)(99) / 243 = Nine similar calculations produce the table of expected counts:

19 Computing the chi-square statistic
The chi-square statistic (c2) is a measure of how much the observed cell counts in a two-way table diverge from the expected cell counts. The formula for the c2 statistic is: (summed over all r x c cells in the table) Tip: First, calculate the c2 components, (observed-expected)2/expected, for each cell of the table, and then sum them up to arrive at the c2 statistic.

20 Music and wine purchase decision
H0: No relationship between music and wine Ha: Music and wine are related Observed counts Expected counts We calculate nine X2 components and sum them to produce the X2 statistic:

21 Table A.7. df = (r−1)(c−1) Ex: In a 4x3 table, df = 3*2 = 6
If X2 = 16.1, the p-value is between 0.01−0.02.

22 Music and wine purchase decision
H0: No relationship between music and wine Ha: Music and wine are related We found that the c2 statistic under H0 is The two-way table has a 3x3 design (3 levels of music and 3 levels of wine). Thus, the degrees of freedom for the c2 distribution for this test is: (r – 1)(c – 1) = (3 – 1)(3 – 1) = 4 16.42 < X2 = < 18.47 > p-value >  very significant There is a significant relationship between the type of music played and wine purchases in supermarkets.


Download ppt "Goodness-of-Fit Tests and Categorical Data Analysis"

Similar presentations


Ads by Google