For problem 6.9 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.
I am defining P(AB) as the probability that a student graduated from college and found a job within one year. I entered the following code into R to calculate the joint probabilities and marginal probabilities for each scenario:
Graduated<-c(348,52,400)
Not.Graduate<-c(0,0,0)
Totals<-c(400,0,400)
Discussion6<-data.frame(cbind(Graduated,Not.Graduate,Totals))
row.names(Discussion6)=c('Job','No Job','Totals')
Joint_Prob<-Discussion6/Discussion6$Totals[3]
Joint_Prob
## Graduated Not.Graduate Totals
## Job 0.87 0 1
## No Job 0.13 0 0
## Totals 1.00 0 1
Should you expect strict equality to hold? Why or why not?
I would expect the equality to hold because the other measures of independence are in place. Our sample of 400 is less than 10% of the overall population of 4,500. In addition, we randomly sampled. Therefore, I would expect our sample to be independent.
Then conduct the Chi Square test using R.
I used created a new table where my expected values were applied to total student population of 4,500.
D6.Observed<-c(348,52)
D6.Expected<-c(3195,585)
chisq.test(D6.Observed,D6.Expected)
## Warning in chisq.test(D6.Observed, D6.Expected): Chi-squared approximation
## may be incorrect
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: D6.Observed and D6.Expected
## X-squared = 0, df = 1, p-value = 1