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 | 20 | 40 | 20 |
B | 40 | 30 | 15 |
C | 45 | 50 | 30 |
Determine the marginal probability P ( Y = L 1 ) = (round to the third decimal place)
Determine the conditional probability P ( X = A | Y = L 1 ) = (round to the second decimal place)
Use R to conduct a chi-square test of independence and thus determine
The marginal probability, P(Y=L1) = Number of occurances corresponding to L1/ Total number of occurances = (20+40+45)/ (20+40+20+40+30+15+45+50+30) = 105/ 290 = 0.362
Now, P(X=A | Y = L1) = P(X=A , Y = L1) / P(Y = L1) = Number of simultaneous occurance of A and L1/ Number of occurances of L1 = 20/(20+40+45) = 0.190
x<-c(rep("A",80),rep("B",85),rep("C",125))
y<-c(rep("L1",20),rep("L2",40),rep("L3",20),rep("L1",40),rep("L2",30),rep("L3",15),
rep("L1",45),rep("L2",50),rep("L3",30))
tbl<-table(x,y)
tbl
chi<-chisq.test(tbl)
chi
Result of chi-square test :-
Degrees of freedom = 4
Chi-square = 9.04
p-value = 0.06
At 5% level of significance our conclusion would be, B
Get Answers For Free
Most questions answered within 1 hours.