Chi-Square Test for multiple-response variables? I have two categorical variables but one of them has multiple responses. After searching online, I came to find the Rao-Scott Chi-Square Test for such data, but little was found about some useful R or Python codes.
Is there anybody who can give me some tips on analyzing the data?
 A: The implementation is fairly straight forward. I've taken the test details from here:
https://www.researchgate.net/publication/26596309_Development_in_Analysis_of_Multiple_Response_Survey_Data_in_Categorical_Data_Analysis_The_Case_of_Enterprise_System_Implementation_in_Large_North_American_Firms
The test statistic is $\chi_C = \frac{\chi}{\delta}$, where $\chi$ is the original test $\chi^2$ test-statitic and $\delta$ is the correction term.
$$ \delta = 1 - \frac{m_{++}}{n_+ \times C} $$
where $m_{++}$ is the number of multiple responses, $n_+$ is the number of subjects and $C$ is the possible number of categories.
The degree of freedom is $(R - 1)\times C$, where $R$ is the number of rows. The implementation in R is
# assume that columns are the multiple categories 
rao_scott_test <- function(mat, subject_num) {
  category_num <- ncol(mat)
  R            <- nrow(mat) 
  
  m_plus_plus  <- sum(mat)
  delta        <- 1 - m_plus_plus / (subject_num * category_num)
  df           <- (R - 1) * category_num
        
  chi_square_stat <- chisq.test(mat)$statistic
  rao_scott_stat  <- chi_square_stat / delta
  
  results <- list()
  results[['statistic']] <- rao_scott_stat
  results[['p_value']]   <- 1 - pchisq(rao_scott_stat, df)
  results[['df']]        <- df 
  
  return(results)
}

# example 
mat <- cbind(c(88, 71), c(100, 36), c(101, 77))
subject_num <- 195 

rao_scott_test(mat, subject_num = 195)

