Hi All,
I have got this dataframe:
dt <- readr::read_fwf("
gender age_group diagnosis
male young x
female child y
female adult x
male old z")
dt %<>%
janitor::row_to_names(row_number = 1)
I have watched this and read this:
https://www.youtube.com/watch?v=LUuLGLGI650
https://stackoverflow.com/questions/34750987/3-way-chi-squared-test-in-r
Like a user Tybran in the comment section said:"I think this video misses one very important detail: the difference between a significant effect (in this case the female group) and the a nonsignificant effect (the male group) is not per se a significant difference of itself. So it is important to recognize that with this method, the three-way interaction is not directly tested but instead 2 two-way interactions are descriptively compared".
Because I believe that R can do what SPSS can't, I want to do sort of chi square test for 4x3 table which would be a task for Cochran-Mantel-Haenszel Test I suppose. I prepared my dt dataframe but when I want to do CMH test it errors to:
Error in mantelhaen.test(dt) : if 'x' is not an array, 'y' must be given
or: when I have done:
dt = table(dt)
mantelhaen.test(dt)
Error in mantelhaen.test(df) : sample size in each stratum must be > 1
How to rectify this, please ? In my opinion there are more than 1 level in each variable in my dt dataframe.