pairwise.chisq.test {jgsbook} | R Documentation |
Pairwise Chi-Square Tests
Description
This function performs pairwise Chi-Square tests for two factors.
Usage
pairwise.chisq.test(A, B, p.adjust.method = "bonferroni")
Arguments
A |
A factor with two or moew levels. The first variable. |
B |
A factor with two or more levels. The second variable. |
p.adjust.method |
A string specifying the method for adjusting p-values. Default is "bonferroni". |
Details
This function creates all possible pairs of levels of factor B and performs a Chi-Square test for each pair of B on variable A. The p-values are adjusted according to the specified method.
#' This function is created for educational purposes only. For exact p-values, consider using reporttools::pairwise.fisher.test()
.
Value
A data frame with the results of the pairwise Chi-Square tests. Includes the groups, Chi-Square statistic, degrees of freedom, p-values, adjusted p-values, and significance stars.
Examples
set.seed(123)
A <- factor(sample(c("Male", "Female"), 100, replace = TRUE))
B <- factor(sample(c("Location1", "Location2", "Location3"), 100, replace = TRUE))
pairwise.chisq.test(A, B, "holm")