mr.chisq.test: Multiple-response chi-square test

View source: R/mr.chisq.test.R

mr.chisq.testR Documentation

Multiple-response chi-square test

Description

Performs a multiple-response chi-square test as defined in Loughin and Scherer (1998) using random permutations to estimate the null distribution

Usage

mr.chisq.test(data, nperm = 2000)

Arguments

data

A data.frame of observations in rows whose first column is a factor (the categories) and subsequent columns are binary numeric or integer, each column being a response option

nperm

Number of permuted datasets to estimate the distribution of the statistic under the null hypothesis. See details

Details

  • nperm: The distribution of the statistic under the null hypothesis of no associations between categories and response options is estimated using nperm datasets generated thanks to random permutations of the response vectors along observations. Note that this differs from the original proposition of Loughin and Scherer (1998) who used a parametric bootstrap to do so.

Value

A list with the following elements:

statistic

Observed multiple-response chi-square statistic

p.value

p-value of the test

References

Loughin, T. M., & Scherer, P. N. (1998). Testing for Association in Contingency Tables with Multiple Column Responses. Biometrics, 54(2), 630-637.

Mahieu, B., Schlich, P., Visalli, M., & Cardot, H. (2021). A multiple-response chi-square framework for the analysis of Free-Comment and Check-All-That-Apply data. Food Quality and Preference, 93.

Examples

nb.obs=200
nb.response=5
nb.category=5
vec.category=paste("C",1:nb.category,sep="")
right=matrix(rbinom(nb.response*nb.obs,1,0.25),nb.obs,nb.response)
category=sample(vec.category,nb.obs,replace = TRUE)
dset=cbind.data.frame(category,right)
dset$category=as.factor(dset$category)


mr.chisq.test(dset)

MahieuB/MultiResponseR documentation built on June 22, 2024, 8:08 a.m.