This might be a question that could be answered relatively quickly if I knew more terminology.
Am I correctly performing a chi-squared test for independence on the JOB
variable?
CD %>% select(JOB, DEFAULT) %>%
table() %>% chisq.test()
unique(CD$JOB)
[1] SkilledEmployee/Official
[2] Unemployed/Unskilled:Resident
[3] Mgr/SelfEmployed/HighlyQualified Employee/Officer
[4] Unemployed/Unskilled:NonResident
4 Levels
Thank You.
CodePudding user response:
You Almost got it right. Null hypothesis would be that the categics are independent. H1 would be they are not independent.
Run the test like this, there is no need for dplyr::select on the df CD.
chisq.test(table(CD$JOB,CD$DEFAULT))
CodePudding user response:
You can do exactly what you want in the way you thought by using chi_test()
from rstatix
package.
I strongly recommend checking out rstatix
. This package makes baseR operation pipe-friendly. So if you like pipe, you will love it.
Solution
library(rstatix)
CD %>%
select(JOB, DEFAULT) %>%
table() %>%
chisq_test()