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?

  • $\begingroup$ can you explain how these data arise? Do you have repeated measures? $\endgroup$
    – utobi
    Commented Oct 12, 2022 at 19:59

1 Answer 1


The implementation is fairly straight forward. I've taken the test details from here:


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 

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

rao_scott_test(mat, subject_num = 195)
  • $\begingroup$ Oh...thank you so much! I will check it. $\endgroup$
    – Sue
    Commented Oct 12, 2022 at 6:27
  • $\begingroup$ If you found the answer helpful you can accept it by clicking the check symbol - meta.stackexchange.com/questions/86978/… $\endgroup$
    – Kozolovska
    Commented Oct 12, 2022 at 13:24
  • 1
    $\begingroup$ Please edit to reflect delta is 1 - (m++/n+C) as found in the code (correctly). $\endgroup$
    – Chris
    Commented Nov 22, 2022 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.