myvector=c(348,52)
mymatrix=matrix(c(348,52,0,0), nrow=2)
colnames(mymatrix) <- c("Grad", "NoGrad")
rownames(mymatrix) <-c("Job", "NoJob")
mymatrix
## Grad NoGrad
## Job 348 0
## NoJob 52 0
myvector2=c(200,200)
mymatrix2=matrix(c(200,200,200,200), nrow=2)
colnames(mymatrix2) <- c("Grad", "NoGrad")
rownames(mymatrix2) <-c("Job", "NoJob")
mymatrix2
## Grad NoGrad
## Job 200 200
## NoJob 200 200
df = (r-1)(c-1) = (2-1)(2-1)=1
alpha = .01
Chi-Square(1,.01) = 6.635
If Chi > 6.635 Reject Ho
If Chi <= 6.635 Do not Reject Ho
Chi Square Value = [(348-200)^2/200]+[(52-200)^2/200] = 219.04
219.04 > 6.635
Reject the null hypothesis that getting a job is independent of graduating.
chisq.test(mymatrix)
## Warning in chisq.test(mymatrix): Chi-squared approximation may be incorrect
##
## Pearson's Chi-squared test
##
## data: mymatrix
## X-squared = NaN, df = 1, p-value = NA