# Statistics for Business and Economics Chapter 9 Categorical Data Analysis.

## Presentation on theme: "Statistics for Business and Economics Chapter 9 Categorical Data Analysis."— Presentation transcript:

Statistics for Business and Economics Chapter 9 Categorical Data Analysis

Learning Objectives 1.Explain 2 Test for Proportions 2.Explain 2 Test of Independence 3.Solve Hypothesis Testing Problems More Than Two Population Proportions Independence

Data Types Data QuantitativeQualitative ContinuousDiscrete

Qualitative Data Qualitative random variables yield responses that classify –Example: gender (male, female) Measurement reflects number in category Nominal or ordinal scale Examples –What make of car do you drive? –Do you live on-campus or off-campus?

Hypothesis Tests Qualitative Data Qualitative Data Z Test 2 Test ProportionIndependence 1 pop. 2 Test More than 2 pop.

Chi-Square ( 2 ) Test for k Proportions

Hypothesis Tests Qualitative Data Qualitative Data Z Test 2 Test ProportionIndependence 1 pop. 2 Test More than 2 pop.

Multinomial Experiment n identical trials k outcomes to each trial Constant outcome probability, p k Independent trials Random variable is count, n k Example: ask 100 people (n) which of 3 candidates (k) they will vote for

One-Way Contingency Table Shows number of observations in k independent groups (outcomes or variable levels) Outcomes (k = 3) Number of responses Candidate TomBillMaryTotal 352045100

: – H: Prof (Tom) = Prob (Mary)=Prof(Bill)=1/3 –H1: Prof (Tom) = 1/3 –H2: Prof (Mary) = 1/3 –H3: Prof (Bill) = 1/3

Calculate the probability of incorrectly rejecting the null using the common sense test based on the three individual t-statistics. To simplify the calculation, suppose that, and are independently distributed. Let t 1 and t 2 be the t-statistics. The common sense test is reject if |t 1 |>1.96 and/or |t 2 | > 1.96 and/or |t 3 | > 1.96. What is the probability that this common sense test rejects H 0 when H 0 is actually true? (It should be 5%.) 11

Probability of incorrectly rejecting the null 12

which is not the desired 5%. 13

The size of a test is the actual rejection rate under the null hypothesis. The size of the common sense test isnt 5%. Its size actually depends on the correlation between t 1 t 2 and t 3 (and thus on the correlation between and ). Two Solutions. Use a different critical value in this procedure - not 1.96 (this is the Bonferroni method). This is rarely used in practice. Use a different test statistic that test at once 14

Chi-Square ( 2 ) Test for k Proportions Tests equality (=) of proportions only –Example: p 1 =.2, p 2 =.3, p 3 =.5 One variable with several levels Uses one-way contingency table

Conditions Required for a Valid Test: One-way Table 1.A multinomial experiment has been conducted 2.The sample size n is large: E(n i ) is greater than or equal to 5 for every cell

2 Test for k Proportions Hypotheses & Statistic 2.Test Statistic Observed count Expected count: E(n i ) = np i,0 3.Degrees of Freedom: k – 1 Number of outcomes Hypothesized probability 1.Hypotheses H 0 : p 1 = p 1,0, p 2 = p 2,0,..., p k = p k,0 H a : At least one p i is different from above

2 Test Basic Idea 1.Compares observed count to expected count assuming null hypothesis is true 2.Closer observed count is to expected count, the more likely the H 0 is true Measured by squared difference relative to expected count Reject large values

Finding Critical Value Example What is the critical 2 value if k = 3, and =.05? 2 0 Upper Tail Area DF.995….95….05 1...…0.004…3.841 20.010…0.103…5.991 2 Table (Portion) If n i = E(n i ), 2 = 0. Do not reject H 0 df= k - 1 = 2 5.991 Reject H 0 =.05

As personnel director, you want to test the perception of fairness of three methods of performance evaluation. Of 180 employees, 63 rated Method 1 as fair, 45 rated Method 2 as fair, 72 rated Method 3 as fair. At the.05 level of significance, is there a difference in perceptions? 2 Test for k Proportions Example

H 0 : H a : = n 1 = n 2 = n 3 = Critical Value(s): Test Statistic: Decision: Conclusion: p 1 = p 2 = p 3 = 1/3 At least 1 is different.05 634572 =.05 2 0 Reject H 0 5.991 2 Test for k Proportions Solution

Test Statistic: Decision: Conclusion: 2 = 6.3 Reject at =.05 There is evidence of a difference in proportions 2 Test for k Proportions Solution H 0 : H a : = n 1 = n 2 = n 3 = Critical Value(s): 2 0 Reject H 0 p 1 = p 2 = p 3 = 1/3 At least 1 is different.05 634572 5.991 =.05

Hypothesis Tests Qualitative Data Qualitative Data Z TestZ, Chi 2 Test ProportionIndependence 1 pop. 2 Test More than 2 pop.

Contingency Table Example Left-Handed vs. Gender Dominant Hand: Left vs. Right Gender: Male vs. Female 2 categories for each variable, so called a 2 x 2 table Suppose we examine a sample of 300 children

Contingency Table Example Sample results organized in a contingency table: (continued) Gender Hand Preference LeftRight Female12108120 Male24156180 36264300 120 Females, 12 were left handed 180 Males, 24 were left handed sample size = n = 300:

H 0 : H a : = n 1 = n 2 = Critical Value(s): Test Statistic: Decision: Conclusion: p 1 = p 2 At least 1 is different.05 1224 =.05 2 0 Reject H 0 3.841 Contingency Table Example Solution

If the two proportions are equal, then P(Left Handed | Female) = P(Left Handed | Male) =.12 i.e., we would expect (.12)(120) = 14.4 females to be left handed (.12)(180) = 21.6 males to be left handed

H 0 : H a : = n 1 = n 2 = Critical Value(s): Test Statistic: Decision: Conclusion: p 1 = p 2 At least 1 is different.05 1224 =.05 2 0 Reject H 0 3.841 Contingency Table Example Solution 2 = 0.7576 Reject at =.05 There is evidence of a difference in proportions

2 Test of Independence

Hypothesis Tests Qualitative Data Qualitative Data Z Test 2 Test ProportionIndependence 1 pop. 2 Test More than 2 pop.

2 Test of Independence Shows if a relationship exists between two qualitative variables –One sample is drawn –Does not show causality Uses two-way contingency table

2 Test of Independence Contingency Table Shows number of observations from 1 sample jointly in 2 qualitative variables Levels of variable 2 Levels of variable 1

Conditions Required for a Valid 2 Test: Independence 1.Multinomial experiment has been conducted 2.The sample size, n, is large: E ij is greater than or equal to 5 for every cell

2 Test of Independence Hypotheses & Statistic 1.Hypotheses H 0 : Variables are independent H a : Variables are related (dependent) 3.Degrees of Freedom: (r – 1)(c – 1) Rows Columns 2.Test Statistic Observed count Expected count

2 Test of Independence Expected Counts 1.Statistical independence means joint probability equals product of marginal probabilities 2.Compute marginal probabilities and multiply for joint probability 3.Expected count is sample size times joint probability

112 160 Marginal probability = Expected Count Example Location UrbanRural House Style Obs. Obs.Total Split–Level 63 49 112 Ranch 15 33 48 Total 78 82 160

78 160 Marginal probability = Expected Count Example 112 160 Marginal probability = Location UrbanRural House Style Obs. Obs.Total Split–Level 63 49 112 Ranch 15 33 48 Total 78 82 160

Expected Count Example 78 160 Marginal probability = 112 160 Marginal probability = Joint probability = 112 160 78 160 Location UrbanRural House Style Obs. Obs.Total Split–Level 63 49 112 Ranch 15 33 48 Total 78 82 160 Expected count = 160· 112 160 78 160 = 54.6

Expected Count Calculation House Location Urban Rural House Style Obs. Exp. Obs. Exp. Total Split-Level 63 112·78 160 54.6 49 112·82 160 57.4 112 Ranch 15 48·78 160 23.4 33 48·82 160 24.6 48 Total 78 82 160

As a realtor you want to determine if house style and house location are related. At the.05 level of significance, is there evidence of a relationship? 2 Test of Independence Example

2 Test of Independence Solution H 0 : H a : = df = Critical Value(s): Test Statistic: Decision: Conclusion: No Relationship Relationship.05 (2 - 1)(2 - 1) = 1 2 0 Reject H 0 3.841 =.05

E ij 5 in all cells 2 Test of Independence Solution 112·82 160 48·78 160 48·82 160 112·78 160

2 Test of Independence Solution

Test Statistic: Decision: Conclusion: 2 = 8.41 Reject at =.05 There is evidence of a relationship H 0 : H a : = df = Critical Value(s): 2 0 Reject H 0 No Relationship Relationship.05 (2 - 1)(2 - 1) = 1 3.841 =.05

Youre a marketing research analyst. You ask a random sample of 286 consumers if they purchase Diet Pepsi or Diet Coke. At the.05 level of significance, is there evidence of a relationship? 2 Test of Independence Thinking Challenge Diet Pepsi Diet CokeNoYesTotal No 84 32116 Yes 48122170 Total132154286

2 Test of Independence Solution* H 0 : H a : = df = Critical Value(s): Test Statistic: Decision: Conclusion: No Relationship Relationship.05 (2 - 1)(2 - 1) = 1 2 0 Reject H 0 3.841 =.05

E ij 5 in all cells 170·132 286 170·154 286 116·132 286 154·132 286 2 Test of Independence Solution*

Test Statistic: Decision: Conclusion: 2 = 54.29 Reject at =.05 There is evidence of a relationship H 0 : H a : = df = Critical Value(s): 2 0 Reject H 0 No Relationship Relationship.05 (2 - 1)(2 - 1) = 1 3.841 =.05

Example The meal plan selected by 200 students is shown below: Class Standing Number of meals per week Total 20/wee k 10/weeknone Fresh.24321470 Soph.22261260 Junior1014630 Senior14161040 Total708842200

Example The hypothesis to be tested is: (continued) H 0 : Meal plan and class standing are independent (i.e., there is no relationship between them) H 1 : Meal plan and class standing are dependent (i.e., there is a relationship between them)

Class Standin g Number of meals per week Total 20/wk10/wknone Fresh.24321470 Soph.22261260 Junior1014630 Senior14161040 Total708842200 Class Standing Number of meals per week Total 20/wk10/wknone Fresh.24.530.814.770 Soph.21.026.412.660 Junior10.513.26.330 Senior14.017.68.440 Total708842200 Observed: Expected cell frequencies if H 0 is true: Example for one cell: Example: Expected Cell Frequencies (continued)

Example: The Test Statistic The test statistic value is: (continued) = 12.592 from the chi-squared distribution with (4 – 1)(3 – 1) = 6 degrees of freedom

Example: Decision and Interpretation (continued) Decision Rule: If > 12.592, reject H 0, otherwise, do not reject H 0 Here, = 0.709 < = 12.592, so do not reject H 0 Conclusion: there is not sufficient evidence that meal plan and class standing are related at = 0.05 2 0.05 =12.592 0 0.05 Reject H 0 Do not reject H 0

Conclusion 1.Explained 2 Test for Proportions 2.Explained 2 Test of Independence 3.Solved Hypothesis Testing Problems More Than Two Population Proportions Independence