The Chi Square Test for Independence literally tests whether P(AB) is “close enough” to being equal to P(A) x P(B). For problem 6.29 in OpenStats, evaluate whether P(AB)=P(A)xP(B) strictly holds by calculating the marginal probabilities for each outcome and multiplying them together then comparing them to the joint probabilities. Should you expect strict equality to hold? Why or why not? Then conduct the Chi Square test using R. Post your solutions and code (screen shots are fine).
myvector=c(154, 180, 104)
mymatrix = matrix(c(154, 180, 104, 132, 126, 131), ncol=2)
colnames(mymatrix) <- c("College Grad", "Not Grad")
rownames(mymatrix) <-c("Support", "Oppose", "Do not Know")
mymatrix
## College Grad Not Grad
## Support 154 132
## Oppose 180 126
## Do not Know 104 131
#Marginal Probabilties
P(SupportGrad) = 154/438 = .352 P(OpposeGrad) = 180/438 = .42 P(DonotknowGrad) = 104/438 = .237 P(SupportNotGrad) = 132/389 = .339 P(OpposeNotGrad) = 126/389 = .324 P(Do notknowNotGrad) = 131/389 = .337 P(Grad)= 438/827 = .53 P(NotGrad)= 389/827 = .47
P(SupportGrad) .352 * .53 = .187 P(OpposeGrad) = .42 * .53 = .222 P(DonotknowGrad) = .237 * .53 = .126 P(SupportNotGrad) = .339 * .47 = .159 P(OpposeNotGrad) = .324 * .47 = .152 P(Do notknowNotGrad) = .337 * .47 = .158 P(Grad)= 438/827 = .53
#Joint Probabilites P(SupportGrad) = 154/827 = .186 P(OpposeGrad) = 180/827 =.217 P(DonotknowGrad) = 104/827 = .126 P(SupportNotGrad) = 132/827 = .16 P(OpposeNotGrad) = 126/827 = .152 P(Do notknowNotGrad) = 131/827 = .158
Strict equaltiy sho not be expeceted if there is rounding as was the case with mine. But if you are dealing with exact answer than strict equality should hold because the numerator and denominator that is the shared condition will go away in the joint probability.
chisq.test(mymatrix)
##
## Pearson's Chi-squared test
##
## data: mymatrix
## X-squared = 11.461, df = 2, p-value = 0.003246
The Chi Square test shows there is significant evidence to reject the null hypothesis