In: Statistics and Probability
Given contingency table for simultaneous occurance of two categorical random variables X (levels A,B,C) and Y (levels L1,L2,L3)
| L1 | L2 | L3 | |
| A | 10 | 20 | 30 |
| B | 15 | 20 | 30 |
| C | 25 | 22 | 32 |
Determine the marginal probability P ( X = B ) = (round to the sthird decimal place)
Determine the conditional probability P ( Y = L 2 | X = B ) = (round to the second decimal place)
Use R to conduct a chi-square test of independence and thus determine
| Observed | L1 | L2 | L3 | Total | |
| A | 10 | 20 | 30 | 60 | |
| B | 15 | 20 | 30 | 65 | |
| C | 25 | 22 | 32 | 79 | |
| total | 50 | 62 | 92 | 204 |
from above
1) P(X=B)=65/204=0.32
2)P(Y=L2 |X=B) =20/65 =0.31
3)
| degree of freedom(df) =(rows-1)*(columns-1)= | 4 | |
4)
| Applying chi square test of independence: |
| Expected | Ei=row total*column total/grand total | L1 | L2 | L3 | Total |
| A | 14.706 | 18.235 | 27.059 | 60 | |
| B | 15.931 | 19.755 | 29.314 | 65 | |
| C | 19.363 | 24.010 | 35.627 | 79 | |
| total | 50 | 62 | 92 | 204 | |
| chi square χ2 | =(Oi-Ei)2/Ei | L1 | L2 | L3 | Total |
| A | 1.506 | 0.171 | 0.320 | 1.9964 | |
| B | 0.054 | 0.003 | 0.016 | 0.0736 | |
| C | 1.641 | 0.168 | 0.369 | 2.1788 | |
| total | 3.2016 | 0.3421 | 0.7051 | 4.2487 | |
| test statistic X2= | 4.249 | ||||
5)
| p value = | 0.373 |
6)
Do not reject that they are independent at 5% significance level and reserve judgement. We may accept independence, but with some unknown probability.