Transcript Slide 1

Analysis of Count Data Chapter 26

Goodness of fit

Formulas and models for two-way tables - tests for independence - tests of homogeneity

Example 1: 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?

Example 2: M & M Colors

  Mars, Inc. periodically changes the M&M (milk chocolate) color proportions. Last year the proportions were: yellow 20%; red 20%, orange, blue, green 10% each; brown 30% In a recent bag of 106 M&M’s I had the following numbers of each color:

Yellow

29 (27.4%)

Red

23 (21.7%)

Orange

12 (11.3%)

Blue

14 (13.2%)

Green

8 (7.5%)

Brown

20 (18.9%)  Is this evidence that Mars, Inc. has changed the color distribution of M&M’s?

Example 3: Are successful people more likely to be born under some astrological signs than others?

 256 executives of Fortune 400 companies have birthday signs shown at the right.

Births

23 20

Sign

Aries Taurus 18 Gemini   There is some variation in the number of births per sign, and there are more

Pisces

.

Can we claim that successful people are more likely to be born under some signs than others?

23 20 19 18 21 19 22 24 29 Cancer Leo Virgo Libra Scorpio Sagittarius Capricorn Aquarius Pisces

To answer these questions we use the chi-square goodness of fit test

Data for

n

observations on a categorical variable (for example, day of week, color of M&M) with

k

possible outcomes (k=5 weekdays, k=6 M&M colors) are summarized as observed counts,

n

1

, n

2

, . . . , n k

in

k

cells.

2 hypotheses: null hypothesis H 0 and alternative hypothesis H A

H

0 specifies probabilities

p

1

, p

2

, . . . , p k

for the possible outcomes.

H A states that the probabilities are different from those in H 0

The Chi-Square Test Statistic

The

Chi-square test statistic

is

:  2 

all

 cells (

Obs

Exp

) 2

Exp

 where: O

bs

= observed frequency in a particular cell

Exp

= expected frequency in a particular cell if H 0 is true The expected frequency in cell

i

is np i

Chi-Square Distributions

The Chi-Square Test Statistic (cont.)

 The χ 2 test statistic approximately follows a chi-squared distribution with

k

-1 degrees of freedom, where

k

is the number of categories.

 2  If the χ 2 test statistic is large, this is evidence against  the null hypothesis.

all

 cells (

Obs

Exp

) 2

Exp

Decision Rule : 2 If .05

,reject H 0 , otherwise, do not reject H 0 .

0 .05

Do not reject H 0  2 .05

Reject H 0  2

Car accidents and day of the week (compare X 2 to table value)

H

0 specifies that all days are equally likely for car accidents  each

p i

= 1

/

5.

The expected count for each of the five days is

np i

= 667

(

1

/

5

)

= 133

.

4.

 (observed - expected) 2 expected   (count day - 133.4) 2 133.4

 8.49

Following the chi square distribution with 5 − 1 = 4 degrees of freedom.

df 1 2 3 4 5 0.25

1.32

2.77

4.11

5.39

6.63

0.2

1.64

3.22

4.64

5.99

7.29

0.15

2.07

3.79

5.32

6.74

8.12

0.1

2.71

4.61

6.25

7.78

9.24

0.05

3.84

5.99

7.81

9.49

11.07

p

0.025

5.02

7.38

9.35

11.14

12.83

0.02

5.41

7.82

9.84

11.67

13.39

0.01

6.63

9.21

11.34

13.28

15.09

0.005

7.88

10.60

12.84

14.86

16.75

0.0025

9.14

11.98

14.32

16.42

18.39

0.001

10.83

13.82

16.27

18.47

20.51

0.0005

12.12

15.20

17.73

20.00

22.11

6 7.84

9.04

8.56

9.80

9.45

10.75

10.64

12.02

12.59

14.07

14.45

16.01

15.03

16.62

16.81

18.48

18.55

20.28

20.25

22.04

22.46

24.32

24.10

we 8 10.22

11.03

do not reject H 0 12.03

13.29

13.36

14.68

15.51

16.92

17.53

19.02

18.17

19.68

20.09

21.67

21.95

23.59

23.77

25.46

26.12

27.88

27.87

29.67

 10 11 12 14 12.55

13.70

13.44

14.63

14.53

15.77

15.99

17.28

18.31

19.68

20.48

21.92

21.16

22.62

23.21

24.72

25.19

26.76

27.11

28.73

29.59

31.26

31.42

33.14

14.85

15.98

17.12

15.81

16.98

18.15

16.99

18.20

19.41

18.55

19.81

21.06

21.03

22.36

23.68

23.34

24.74

26.12

24.05

25.47

26.87

26.22

27.69

29.14

28.30

29.82

31.32

30.32

31.88

33.43

32.91

34.53

36.12

34.82

36.48

38.11

30 40 50 60 80 100 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 18.25

19.37

20.49

21.60

22.72

23.83

24.93

26.04

27.14

28.24

29.34

30.43

31.53

32.62

33.71

34.80

45.62

56.33

66.98

88.13

109.10

19.31

20.47

21.61

22.76

23.90

25.04

26.17

27.30

28.43

29.55

30.68

31.79

32.91

34.03

35.14

36.25

47.27

58.16

68.97

90.41

111.70

20.60

21.79

22.98

24.16

25.33

26.50

27.66

28.82

29.98

31.13

32.28

33.43

34.57

35.71

36.85

37.99

49.24

60.35

71.34

93.11

114.70

22.31

23.54

24.77

25.99

27.20

28.41

29.62

30.81

32.01

33.20

34.38

35.56

36.74

37.92

39.09

40.26

51.81

63.17

74.40

96.58

118.50

25.00

26.30

27.59

28.87

30.14

31.41

32.67

33.92

35.17

36.42

37.65

38.89

40.11

41.34

42.56

43.77

55.76

67.50

79.08

101.90

124.30

27.49

28.85

30.19

31.53

32.85

34.17

35.48

36.78

38.08

39.36

40.65

41.92

43.19

44.46

45.72

46.98

59.34

71.42

83.30

106.60

129.60

28.26

29.63

31.00

32.35

33.69

35.02

36.34

37.66

38.97

40.27

41.57

42.86

44.14

45.42

46.69

47.96

60.44

72.61

84.58

108.10

131.10

30.58

32.00

33.41

34.81

36.19

37.57

38.93

40.29

41.64

42.98

44.31

45.64

46.96

48.28

49.59

50.89

63.69

76.15

88.38

112.30

135.80

32.80

34.27

35.72

37.16

38.58

40.00

41.40

42.80

44.18

45.56

46.93

48.29

49.64

50.99

52.34

53.67

66.77

79.49

91.95

116.30

140.20

34.95

36.46

37.95

39.42

40.88

42.34

43.78

45.20

46.62

48.03

49.44

50.83

52.22

53.59

54.97

56.33

69.70

82.66

95.34

120.10

144.30

37.70

39.25

40.79

42.31

43.82

45.31

46.80

48.27

49.73

51.18

52.62

54.05

55.48

56.89

58.30

59.70

73.40

86.66

99.61

124.80

149.40

39.72

41.31

42.88

44.43

45.97

47.50

49.01

50.51

52.00

53.48

54.95

56.41

57.86

59.30

60.73

62.16

76.09

89.56

102.70

128.30

153.20

Car accidents and day of the week (bounds on P-value)

H

0 specifies that all days are equally likely for car accidents  each

p i

= 1

/

5.

The expected count for each of the five days is

np i

= 667

(

1

/

5

)

= 133

.

4.

 (observed - expected) 2 expected   (count day - 133.4) 2 133.4

 8.49

Following the chi square distribution with 5 − 1 = 4 degrees of freedom.

30 40 50 60 80 100 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 df 1 2 3 4 0.25

1.32

2.77

4.11

5.39

18.25

19.37

20.49

21.60

22.72

23.83

24.93

26.04

27.14

28.24

29.34

30.43

31.53

32.62

33.71

34.80

45.62

56.33

66.98

88.13

109.10

0.2

1.64

3.22

4.64

5.99

19.31

20.47

21.61

22.76

23.90

25.04

26.17

27.30

28.43

29.55

30.68

31.79

32.91

34.03

35.14

36.25

47.27

58.16

68.97

90.41

111.70

0.15

2.07

3.79

5.32

6.74

20.60

21.79

22.98

24.16

25.33

26.50

27.66

28.82

29.98

31.13

32.28

33.43

34.57

35.71

36.85

37.99

49.24

60.35

71.34

93.11

114.70

0.1

2.71

4.61

6.25

7.78

22.31

23.54

24.77

25.99

27.20

28.41

29.62

30.81

32.01

33.20

34.38

35.56

36.74

37.92

39.09

40.26

51.81

63.17

74.40

96.58

118.50

0.05

3.84

5.99

7.81

9.49

25.00

26.30

27.59

28.87

30.14

31.41

32.67

33.92

35.17

36.42

37.65

38.89

40.11

41.34

42.56

43.77

55.76

67.50

79.08

101.90

124.30

p

0.025

5.02

7.38

9.35

11.14

27.49

28.85

30.19

31.53

32.85

34.17

35.48

36.78

38.08

39.36

40.65

41.92

43.19

44.46

45.72

46.98

59.34

71.42

83.30

106.60

129.60

0.02

5.41

7.82

9.84

11.67

28.26

29.63

31.00

32.35

33.69

35.02

36.34

37.66

38.97

40.27

41.57

42.86

44.14

45.42

46.69

47.96

60.44

72.61

84.58

108.10

131.10

0.01

6.63

9.21

11.34

13.28

30.58

32.00

33.41

34.81

36.19

37.57

38.93

40.29

41.64

42.98

44.31

45.64

46.96

48.28

49.59

50.89

63.69

76.15

88.38

112.30

135.80

0.005

7.88

10.60

12.84

14.86

32.80

34.27

35.72

37.16

38.58

40.00

41.40

42.80

44.18

45.56

46.93

48.29

49.64

50.99

52.34

53.67

66.77

79.49

91.95

116.30

140.20

0.0025

9.14

11.98

14.32

16.42

34.95

36.46

37.95

39.42

40.88

42.34

43.78

45.20

46.62

48.03

49.44

50.83

52.22

53.59

54.97

56.33

69.70

82.66

95.34

120.10

144.30

0.001

10.83

13.82

16.27

18.47

0.0005

12.12

15.20

17.73

20.00

5 6.63

11.39

7.29

12.24

8.12

13.29

9.24

14.68

11.07

16.92

12.83

19.02

13.39

19.68

15.09

21.67

16.75

23.59

18.39

25.46

20.51

22.11

6 7 7.78 < X 2 = 8.49 < 9.49

Thus the bounds on the P-value are 0.05 <

P-value

9.04

10.22

9.80

11.03

10.75

12.03

12.02

13.36

14.07

15.51

16.01

17.53

16.62

18.17

18.48

20.09

20.28

21.95

22.04

23.77

24.32

26.12

< 0.1

26.02

27.87

27.88

29.67

 10 11 12 13 12.55

There is no significant evidence of different car accident rates for different 33.14

14.85

15.98

13.44

15.81

16.98

14.53

16.99

18.20

15.99

18.55

19.81

18.31

21.03

22.36

20.48

23.34

24.74

21.16

24.05

25.47

23.21

26.22

27.69

25.19

28.30

29.82

27.11

30.32

31.88

29.59

32.91

34.53

31.42

34.82

36.48

14 17.12

18.15

19.41

21.06

23.68

26.12

26.87

29.14

31.32

33.43

36.12

38.11

37.70

39.25

40.79

42.31

43.82

45.31

46.80

48.27

49.73

51.18

52.62

54.05

55.48

56.89

58.30

59.70

73.40

86.66

99.61

124.80

149.40

39.72

41.31

42.88

44.43

45.97

47.50

49.01

50.51

52.00

53.48

54.95

56.41

57.86

59.30

60.73

62.16

76.09

89.56

102.70

128.30

153.20

Using software

The chi-square function in

Excel

does not compute expected counts automatically but instead lets you provide them. This makes it easy to test for goodness of fit. You then get the test’s p-value—but no details of the

X

2 calculations.

=CHITEST(array of actual values, array of expected values)

with values arranged in two similar

r

*

c

tables --> returns the p value of the Chi Square test

Example 2: M & M Colors

 H 0 : p yellow =.20, p red =.20, p orange =.10, p blue =.10, p green =.10, p brown =.30

Obs.

Exp.

Yellow

29 21.2

Red

23 21.2

Orange

12 10.6

Blue

14 10.6

Green

8 10.6

Brown

20 31.8

Total

106 106  Expected yellow = 106*.20 = 21.2, etc. for other expected counts.

 2 

all

 cells (

Obs

Exp

) 2

Exp

 (29  21.2) 2 21.2

 (23  21.2) 2 21.2

(12   10.6) 10.6

2.87

 2  0.153

(14   10.6) 10.6

0.185

2  (8  10.6)  1.091

 10.6

0.638

2   (20 4.379

 31.8) 31.8

2  9.316

Example 2: M & M Colors (cont.)

 2

 9.316;degrees of freedom

The test statistic is

χ

2  9.316 ;

χ

2 0.05

with 5 d.f.  11.070

0 0.05

Do not reject H 0 Reject H 0  2 0.05 = 11.070

 2 Decision Rule : If 2 .05

,reject H 0 , otherwise, do not reject H 0 .

Here,

χ

2

χ

2 so we do not reject H 0 and conclude that there is not sufficient evidence to conclude that Mars has changed the color proportions.

Chi-Squared test for Normality

The goodness of fit Chi-squared test can be used to determined if data were drawn from any distribution.

The multinomial experiment produces the test statistic.

interval (z i , z i+1 ) is at least 5 .

Testing goodness of fit for the normal distribution 3 > 5 np 3 np 2 > 5 > 5 np 2 > 5 Test the hypotheses: H 0 : P 1 = p 1 ,…, P k = p k H 1 : At least one proportions differs from its specified value. np 1 > 5 p 1 p 2 p 3 p 3 p 2 p 1 np 1 > 5 z 1 z 2 z 3 z 4

Example

: For a sample size of n=50 ,the sample mean was 460.38 with standard error of 38.83. Can we infer from this data that this sample was selected from an approx. normal distribution with  = 460.38 and s = 38.83? Use 5% significance level.

z

Solution

First let us select z values that define each cell (expected frequency > 5 for each cell.) 1 = -1; P(z < -1) = p 1 = .1587; e 1 = np 1 = 50(.1587) = 7.94

z 2 z 3 = 0; P(-1 < z< 0) = p 2 = .3413; e 2 = 1; P(0 < z < 1) = p 3 P(z > 1) = p 4 = .3413; e = .1587; e 4 3 = np = 7.94

2 = 50(.3413) = 17.07

= 17.07

The cell boundaries are calculated from the corresponding z values determined above.

z 1 x 1 =(x 1 - 460.38)/38.83 = -1; = 421.55 The frequencies per cell can now be determined Expected frequencies e

f 1

1

= 10

p 1 e 2

f 3 = 19

Sample = 17.07e

3 frequencies

f 2 = 13

p 2 p 2

f 4 = 8

e p 1 = 7.94

421.55 460.38 499.21

– The test statistic

 2 = (10 - 7.94) 2 7.94

+ (13 - 17.07) 2 17.07

– The rejection region

+ ( 19 - 17.07) 2 17.07

+ (8 - 7.94) 2 7.94

= 1.72

 2

 2  , k  3  2  ,

k

 3   2 .

05 , 4  3 

3 .

84146

Conclusion: There is insufficient evidence to conclude at 5% significance level that the data are not approx. normally distributed.

Models for two-way tables

The chi-square test is an overall technique for comparing any number of population proportions, testing for evidence of a relationship between two categorical variables. There are 2 types of tests:

1.

Test for independence:

Take one SRS and classify the individuals in the sample according to two categorical variables (attribute or condition)  observational study, historical design.

2.

Compare several populations (tests for homogeneity):

Randomly select several SRSs each from a different population (or from a population subjected to different treatments)  experimental study.

Both models use the

X

2 test to test of the hypothesis of

no relationship

.

Testing for independence

We have now a

single

sample from a

single

population. For each individual in this SRS of size

n

we measure two categorical variables. The results are then summarized in a two-way table.

The null hypothesis is that the row and column variables are independent. The alternative hypothesis is that the row and column variables are dependent.

Chi-square tests for independence

 2 

all

 cells (

Obs

Exp

) 2

Exp

 Expected cell frequencies:

Exp

n

Where: row total = sum of all frequencies in the row column total = sum of all frequencies in the column n = overall sample size H 0 : The two categorical variables are independent (i.e., there is no relationship between them) H 1 : The two categorical variables are dependent (i.e., there is a relationship between them)

Example 1: Parental smoking

 Does parental smoking influence the incidence of smoking in children when they reach high school? Randomly chosen high school students were asked whether they smoked (columns) and whether their parents smoked (rows).

Parent

Both smoke One smokes Neither smokes Total

Student

Smoke No smoke Total 400 416 1380 1823 1780 2239 188 1004 1168 4371 1356 5375    Are parent smoking status and student smoking status related?

H 0 : parent smoking status and student smoking status are independent H A : parent smoking status and student smoking status are not independent

Example 1: Parental smoking (cont.)

Does parental smoking influence the incidence of smoking in children when they reach high school? Randomly chosen high school students were asked whether they smoked (columns) and whether their parents smoked (rows). Examine the computer output for the chi-square test performed on these data. What does it tell you?

Hypotheses?

Are data ok for  2 test? (All expected counts 5 or more) df = (rows-1)*(cols-1)=2*1=2 Interpretation? Since P-value is less than .05, reject H 0 and conclude that parent smoking status and student smoking status are related.

Example 2: meal plan selection

 The meal plan selected by 200 students is shown below: Class Standing Fresh.

Number of meals per week 20/week 10/week none 24 32 14 Soph.

Junior 22 10 26 14 12 6 Senior Total 14 70 16 88 10 42 Total 70 60 30 40 200

Example 2: meal plan selection (cont.)

The hypotheses to be tested are:

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)

Example 2: meal plan selection (cont.) Expected Cell Frequencies

Class Standing Fresh.

Soph.

Junior Senior Total Observed: Number of meals per week 20/wk 10/wk none 24 22 10 14 70 32 26 14 16 88 14 12 6 10 42 Example for one cell:

Exp

  200 n  10.5

Total 70 60 30 40 200 Class Standing Fresh.

Soph.

Junior Senior Total Expected cell frequencies if H 0 true: is Number of meals per week 20/wk 24.5

10/wk 30.8

none 14.7

21.0

10.5

26.4

13.2

12.6

6.3

14.0

70 17.6

88 8.4

42 Total 70 60 30 40 200

Example 2: meal plan selection (cont.) The Test Statistic

 The test statistic value is:  2 

all

 cells (

Obs

Exp

) 2

Exp

 24.5

2  30.8

2   8.4

2  0.709

χ

2 0. 05

= 12.592 from the chi-squared distribution with (4 – 1)(3 – 1) = 6 degrees of freedom

Example 2: meal plan selection (cont.) Decision and Interpretation

The test statistic is  2  0.709 ;  2 0.05

with 6 d.f.  12.592

If  > 12.592, reject H 0 , otherwise, do not reject H 0 0.05

0 Do not reject H 0 Reject H 0  2 0.05

=12.592

 2 Here,  2

χ

2 0. 05

so do not reject H 0 Conclusion: there is not sufficient evidence that meal plan and class standing are related.

Models for two-way tables

The chi-square test is an overall technique for comparing any number of population proportions, testing for evidence of a relationship between two categorical variables. There are 2 types of tests:

1.

Test for independence:

Take one SRS and classify the individuals in the sample according to two categorical variables (attribute or condition)  observational study, historical design.

NEXT:

2. Compare several populations (tests for homogeneity):

Randomly select several SRSs each from a different population (or from a population subjected to different treatments)  experimental study.

Both models use the

X

2 test to test of the hypothesis of

no relationship

.

Comparing several populations (tests for homogeneity)

Select independent SRSs from each of

c

populations, of sizes

n

1

, n

2 ,

. . . , n c

. Classify each individual in a sample according to a categorical response variable with

r

possible values. There are

c

different probability distributions, one for each population.

The null hypothesis is that the distributions of the response variable are the same in all

c

populations. The alternative hypothesis says that these

c

distributions are not all the same.

Chi-Square Test for Homogeneity Appropriate when the following conditions are met:

1. Observed counts are from independently selected random samples or subjects in an experiment are randomly assigned to treatment groups .

2. The sample sizes are large . The sample size is large enough for the chi-square test for homogeneity if every expected count is 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.

Chi-Square Test for Homogeneity

When the conditions above are met and the null hypothesis is true, the X 2 statistic has a chi-square distribution with df = (number of rows – 1)(number of columns – 1)

Chi-Square Test for Homogeneity Hypothesis:

H 0 : the population (or treatment) category proportions are the same for all the populations (or treatments) H a : the population (or treatment) category proportions are not all the same for all the populations (or treatments)

Associated P-value:

The P-value associated with the computed test statistic value is the under the chi-square curve with df = (no. of rows – 1)(no. of cols. – 1) area to the right of X 2

A study was conducted to determine if collegiate soccer players had in increased risk of concussions over other athletes or students. The in two-way frequency table independently selected random samples below displays the number of previous concussions for students of 91 soccer players, 96 non-soccer athletes, and 53 non-athletes.

Soccer Players Non-Soccer Players Non-Athletes Total 0 45 68 45 158 Number of Concussions 1 25 15 5 45 2 11 8 3 22 3 or more 10 5 0 15 Total 91 96 53 240 This is univariate categorical data number of concussions - from 3 independent samples.

A study was conducted to determine if collegiate soccer players had in increased risk of concussions over other athletes or students. The in two-way frequency table displays the number of previous concussions for students independently selected random samples below of 91 soccer players, 96 non-soccer athletes, and 53 non-athletes.

Observed (Expected) (91*158)/240 = 59.9

Soccer Players Non-Soccer Players Non-Athletes Total 0 45 (59.9) 68 (63.2) 45 (34.9) 158 Number of Concussions 1 2 3 or more 25 (17.1) 15 (18.0) 5 (10.0) 45 11 (8.3) 8 (8.8) 3 (4.9) 22 10 (5.7) 5 (6.0) 0 (3.3) 15 Total 91 96 53 240 The expected counts are shown in parentheses. Notice that two of the expected counts are less than 5.

Risky Soccer Continued . . .

Soccer Players Non-Soccer Players Non-Athletes Total 0 45 (59.9) 68 (63.2) 45 (34.9) 158 Number of Concussions 1 2 or more 25 (17.1) 15 (18.0) 5 (10.0) 45 21 (14.0) 13 (14.8) 3 (8.2) 37 Total 91 96 53 240

Hypotheses:

H 0 : Proportions in each head injury category are the same for all three groups.

H a : The head injury category proportions are not all the same for all three groups.

Risky Soccer Continued . . . test statistic

Observed (Expected)

Number of Concussions 0 1 2 or more Total Soccer Players Non-Soccer Players Non-Athletes 2  3.71

59.9

45 (59.9) 68 (63.2) 45 (34.9) 158 25 (17.1) 15 (18.0) 5 (10.0) 45 21 (14.0) 13 (14.8) 3 (8.2) 37 91 96 53 240

Cell-by-cell chi-square test statistic values

Number of Concussions 0 1 2 or more Soccer Players Non-Soccer Players Non-Athletes 3.71

0.36

2.92

3.65

0.50

2.50

3.50

0.22

3.30

df=(3-1)*(3-1)=4  2   20.66

Risky Soccer Continued . . . P-value

0  2 0.05

with 4 d.f.  9.49

0.05

P-value: P(  2 4df > 20.66); P-value < 0.001

Do not reject H 0 Reject H 0  2 0.05

=9.49

20.66

 2

H

Risky Soccer Continued . . . Conclusion

P-value < 0.001. Because the P-value is less than 0.05, 0 is rejected. There is strong evidence that the proportions in the head injury categories are not the same for the three groups. How do they differ? Check cell residuals.

cell residual: (

obs

 exp) exp

59.9

Residuals (obs-exp)/√(exp)

Soccer Players Non-Soccer Players Non-Athletes Number of Concussions 0 1 2 or more -1.93

0.60

1.71

1.91

-0.71

-1.58

1.87

-0.47

-1.82

Example: Cocaine addiction (test for homogeneity)

Cocaine produces short-term feelings of physical and mental well being. To maintain the effect, the drug may have to be taken more frequently and at higher doses. After stopping use, users will feel tired, sleepy, and

depressed.

The pleasurable high followed by unpleasant after-effects encourage repeated compulsive use, which can easily lead to dependency.

We compare treatment with an anti depressant (desipramine), a standard treatment (lithium), and a placebo.

Population 1:

Antidepressant treatment (desipramine)

Population 2:

Standard treatment (lithium)

Population 3:

Placebo (“sugar pill”)

Cocaine addiction

H

0 : The proportions of success (no relapse) are the same in all three populations.

Observed 35% Expected 35% 35%

Expected relapse counts

Desipramine No Yes 25*26/74 ≈ 8.78

25*

0.35

16.22

25*0.65

Lithium Placebo 9.14

26*

0.35

8.08

23*

0.35

16.86

25*0.65

14.92

25*0.65

Cocaine addiction

Table of counts: “actual /

expected

,” with three rows and two columns: df = (3 −1)*(2−1) = 2 Desipramine Lithium Placebo No relapse 15

8.78

7

9.14

4

8.08

 2   15  8 .

78   10   7  8 .

78 9 .

14   19   4  9 .

14 8 .

08   19 8 .

08  10 .

74  16 .

22  2  16 .

22 16 .

86  2 16 .

86  14 .

92  2 14 .

92 Relapse 10

16.22

19

16.86

19

14.92

 2 components: 4.41

0.50

2.06

2.39

0.27

1.12

Cocaine addiction: Table χ

H

0 : The proportions of success (no relapse) are the same in all three populations.

22 23 24 25 26 27 28 29 30 40 50 60 80 100 8 9 10 11 12 4 5 6 7 df 1 2 3 0.25

1.32

2.77

4.11

5.39

6.63

7.84

9.04

10.22

11.39

12.55

13.70

14.85

0.2

1.64

3.22

4.64

5.99

7.29

8.56

9.80

11.03

12.24

13.44

14.63

15.81

0.15

2.07

3.79

5.32

6.74

8.12

9.45

10.75

12.03

13.29

14.53

15.77

16.99

0.1

2.71

4.61

6.25

7.78

9.24

10.64

X 2

13.36

14.68

15.99

0.05

3.84

5.99

7.81

9.49

11.07

12.59

15.51

p

0.025

5.02

7.38

9.35

11.14

12.83

14.45

17.53

0.02

5.41

7.82

9.84

11.67

13.39

15.03

18.17

 18.31

reject the

H

0 20.48

21.16

 14 16 18 19 15.98

17.12

18.25

19.37

20.49

21.60

22.72

16.98

18.15

19.31

20.47

21.61

22.76

23.90

18.20

19.41

20.60

21.79

22.98

24.16

25.33

17.28

18.55

19.81

21.06

22.31

23.54

24.77

25.99

27.20

19.68

21.03

22.36

23.68

25.00

26.30

27.59

28.87

30.14

21.92

23.34

24.74

26.12

27.49

28.85

30.19

31.53

32.85

22.62

24.05

25.47

26.87

28.26

29.63

31.00

32.35

33.69

20 23.83

24.93

25.04

26.17

26.50

27.66

28.41

29.62

31.41

32.67

34.17

35.48

35.02

 26.04

27.14

28.24

29.34

30.43

31.53

32.62

33.71

34.80

45.62

56.33

66.98

88.13

109.10

27.30

28.43

29.55

30.68

31.79

32.91

34.03

35.14

36.25

47.27

58.16

68.97

90.41

111.70

28.82

29.98

31.13

32.28

33.43

34.57

35.71

36.85

37.99

49.24

60.35

71.34

93.11

114.70

30.81

32.01

33.20

34.38

35.56

36.74

37.92

39.09

40.26

51.81

63.17

74.40

96.58

118.50

33.92

35.17

36.42

37.65

38.89

40.11

41.34

42.56

43.77

55.76

67.50

79.08

101.90

124.30

36.78

38.08

39.36

40.65

41.92

43.19

44.46

45.72

46.98

59.34

71.42

83.30

106.60

129.60

37.66

38.97

40.27

41.57

42.86

44.14

45.42

46.69

47.96

60.44

72.61

84.58

108.10

131.10

0.01

6.63

9.21

11.34

13.28

15.09

16.81

20.09

21.67

23.21

24.72

26.22

27.69

29.14

30.58

32.00

33.41

34.81

36.19

37.57

38.93

40.29

41.64

42.98

44.31

45.64

46.96

48.28

49.59

50.89

63.69

76.15

88.38

112.30

135.80

40.00

41.40

42.80

44.18

45.56

46.93

48.29

49.64

50.99

52.34

53.67

66.77

79.49

91.95

116.30

140.20

0.005

7.88

10.60

12.84

14.86

16.75

18.55

20.28

21.95

23.59

25.19

26.76

28.30

29.82

31.32

32.80

34.27

35.72

37.16

38.58

0.0025

9.14

11.98

14.32

16.42

18.39

20.25

22.04

23.77

25.46

27.11

28.73

30.32

0.001

10.83

13.82

16.27

18.47

20.51

22.46

24.32

26.12

27.88

29.59

31.26

32.91

0.0005

12.12

15.20

17.73

20.00

22.11

24.10

26.02

27.87

29.67

31.42

33.14

34.82

31.88

33.43

34.53

Observed 36.48

38.11

34.95

36.46

37.95

39.42

40.88

42.34

43.78

45.20

46.62

48.03

49.44

50.83

52.22

53.59

54.97

56.33

69.70

82.66

95.34

120.10

144.30

37.70

39.25

40.79

42.31

43.82

45.31

46.80

48.27

49.73

51.18

52.62

54.05

55.48

56.89

58.30

59.70

73.40

86.66

99.61

124.80

149.40

39.72

41.31

42.88

44.43

45.97

47.50

49.01

50.51

52.00

53.48

54.95

56.41

57.86

59.30

60.73

62.16

76.09

89.56

102.70

128.30

153.20

Avoid These Common Mistakes

Avoid These Common Mistakes 1. Don’t confuse tests for homogeneity with tests for independence. The hypotheses and conclusions are different for the two types of test.

Tests for homogeneity are used when the individuals in each of two or more independent samples are classified according to a single categorical variable .

Tests for independence are used when individuals in a single sample are classified according to two categorical variables .

Avoid These Common Mistakes 2. Remember that a hypothesis test can never show strong support for the null hypothesis.

For example, if you do not reject the null hypothesis in a chi-square test for independence, you cannot conclude that there is convincing evidence that the variables are independent . You can only say that you were not convinced that there is an association between the variables.

Avoid These Common Mistakes 3. Be sure that the conditions for the chi-square test are met.

P-values based on the chi-square distribution are only approximate, and if the large sample condition is not met, the actual P-value may be quite different from the approximate one based on the chi-square distribution.

Also, for the chi-square test of homogeneity, the assumption of independent samples is particularly important.

Avoid These Common Mistakes 4. Don’t jump to conclusions about causation. Just as a strong correlation between two numerical variables does not mean that there is a cause-and-effect relationship between them, an association between two categorical variables does not imply a causal relationship.