mr.sig.cell: Multiple-response tests per cell

View source: R/mr.sig.cell.R

mr.sig.cellR Documentation

Multiple-response tests per cell

Description

This function performs for each pair of category and response option a multiple-response hypergeometric test as defined in Mahieu, Schlich, Visalli, and Cardot (2021) using random hypergeometric samplings to estimate the null distribution

Usage

mr.sig.cell(data, nsample = 2000, nbaxes.sig = Inf, two.sided = TRUE)

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

nsample

Number of randomly sampled datasets to estimate the distribution of the value under the null hypothesis. See details

nbaxes.sig

The number of significant axes retuned by mr.dimensionality.test. By default, all axes are considered significant. See details

two.sided

Logical. Should the tests be two-sided or not?

Details

  • nsample: The distribution of the value under the null hypothesis of no associations between categories and response options is estimated using nsample datasets generated thanks to random hypergeometric samplings of the response vectors along observations.

  • nbaxes.sig: If nbaxes.sig is lower than the total number of axes then the tests are performed on the derived contingency table corresponding to significant axes (Mahieu, Schlich, Visalli, & Cardot, 2021). This table is obtained by using the reconstitution formula of MR-CA on the first nbaxes.sig axes.

Value

A list with the following elements:

original.cont

Observed number of times each category chosen each response option

percent.cont

Within each category, percentage of observations where the response options were chosen

null.cont

Expected number of times each category chosen each response option under the null hypothesis

p.values

P-values of the tests per cell fdr adjusted by response option

derived.cont

The derived contingency table corresponding to nbaxes.sig axes

percent.derived.cont

Within each category, percentage of observations where the response options were chosen in the derived contingency table corresponding to nbaxes.sig axes

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)

res=mr.sig.cell(dset)

plot(res)

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