Docsity

STAT 515 Practice 3: Chi-Square Test for Contingency Tables, Exams of Data Analysis & Statistical Methods

Toggle sidebar
bg1
STAT 515 - Practice 3 Solutions
Pg 714: 13.15a by hand OR SAS. Also state the null and alternate hypothesis in terms of the parameters and the
problem, and check the assumptions.
H0: p0=0.26, p1=0.30, p2=0.11, p3=0.14, p4=0.19
HA: not H0
The expected values in this case would be 85*.26=22.1, 85*.30=25.5, 85*.11=9.35, 85*.14=11.9, and
85*.19=16.15... as all of these are greater than five the test should be reliable.
By SAS:
DATA avonex;
INPUT exacerbations $ count;
CARDS;
032
126
215
36
4plus 6
;
PROC FREQ DATA=avonex ORDER=data;
TABLES exacerbations / TESTP=(.26,.30,.11,.14,.19);
WEIGHT count;
RUN;
Chi-Square Test
for Specified Proportions
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
Chi-Square 17.1631
DF 4
Pr > ChiSq 0.0018
With a p-value of 0.0018 (much less than α
αα
α=0.05) we reject the null hypothesis and conclude that there is
a difference.
By hand:
=
−
+
−
+
−
+
−
+
−
∑=
−
=15.16
2
)15.166(
9.11
2
)9.116(
35.9
2
)35.915(
5.25
2
)5.2526(
1.22
2
)1.2232(
2
)(
2
Exp
ExpObs
χ
17.16313
We compare this to 9.48773 (df=5-1=4, α
αα
α=0.05) and reject the null hypothesis (so we conclude there is a
difference).
Pg. 732: 13.35 b-d by hand and by SAS. Is the sample size large enough? Is this a test of homogeneity or of
independence? Why?
DATA tumors;
INPUT tumors $ diet $ count;
CARDS;
Y High_No 27
Y High_Fib 20
Y Low_No 19
Y Low_Fib 14
N High_No 3
N High_Fib 10
N Low_No 11
N Low_Fib 16
;
PROC FREQ DATA=tumors ORDER=DATA;
WEIGHT count;
TABLES tumors*diet / chisq expected nopercent;
RUN;
pf2

Partial preview of the text

Download STAT 515 Practice 3: Chi-Square Test for Contingency Tables and more Exams Data Analysis & Statistical Methods in PDF only on Docsity!

STAT 515 - Practice 3 Solutions

Pg 714: 13.15a by hand OR SAS. Also state the null and alternate hypothesis in terms of the parameters and the

problem, and check the assumptions.

H 0 : p 0 =0.26, p 1 =0.30, p 2 =0.11, p 3 =0.14, p 4 =0.

H A: not H 0

The expected values in this case would be 85.26=22.1, 85.30=25.5, 85.11=9.35, 85.14=11.9, and

85*.19=16.15... as all of these are greater than five the test should be reliable.

By SAS:

DATA avonex; INPUT exacerbations $ count; CARDS; 0 32 1 26 2 15 3 6 4plus 6 ;

PROC FREQ DATA=avonex ORDER=data; TABLES exacerbations / TESTP=(.26,.30,.11,.14,.19); WEIGHT count; RUN; Chi-Square Test for Specified Proportions ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Chi-Square 17. DF 4 Pr > ChiSq 0.

With a p-value of 0.0018 (much less than αααα =0.05) we reject the null hypothesis and conclude that there is

a difference.

By hand:

2 ( )^2 (^3222.^1 )

Exp

Obs Exp

We compare this to 9.48773 (df=5-1=4, αααα =0.05) and reject the null hypothesis (so we conclude there is a

difference).

Pg. 732: 13.35 b-d by hand and by SAS. Is the sample size large enough? Is this a test of homogeneity or of

independence? Why?

DATA tumors; INPUT tumors $ diet $ count; CARDS; Y High_No 27 Y High_Fib 20 Y Low_No 19 Y Low_Fib 14 N High_No 3 N High_Fib 10 N Low_No 11 N Low_Fib 16 ; PROC FREQ DATA=tumors ORDER=DATA; WEIGHT count; TABLES tumors*diet / chisq expected nopercent; RUN;

Frequency‚

ExpectedExpectedExpectedExpected ‚

Row Pct ‚ Col Pct ‚High_No ‚High_Fib‚Low_No ‚Low_Fib ‚ Total ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ Y ‚ 27 ‚ 20 ‚ 19 ‚ 14 ‚ 80

ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ N ‚ 3 ‚ 10 ‚ 11 ‚ 16 ‚ 40

ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ Total 30 30 30 30 120

Statistics for Table of tumors by diet

Statistic DF Value Prob ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

Chi-Square 3 12.900012.900012.900012.9000 0.00490.00490.00490.

By SAS:

b) As can be seen from the highlighted portions of the contingency table above the expected values are all

20 for the cancer groups and 10 for the non-cancer groups.

c) As can be seen from the statistics table the χχχχ

value is 12.900.

d) With a p-value of 0.0049 (compared to αααα =0.05) we reject the null hypothesis and find that they are not

independent.

By Hand:

b) The table of expected values is the row total times the column total divided by the grand total

Diet

Cancer | High/No High/Fib Low/No Low/Fib

Yes | 8030/120=20 8030/120=20 8030/120=20 8030/120=

No | 4030/120=10 4030/120=10 4030/120=10 4030/120=

c)

d) We compare 12.9 (the χχχχ

) to 7.18473 (df=(4-1)(2-1)=3, αααα =0.05) and reject the null hypothesis (so we

conclude they are not independent).

It is a test of homogeneity because the column totals of 30 are fixed. (Note... in this case the row totals

were not fixed, but if you turned the table sideways they would have been!)

2 ( )^2 (^2720 )

Exp

Obs Exp