library("psych350lab")
# Using Superman data: test relationship between type (3 levels) and tomatometer (2 levels)
result <- chi_square_kgroup_answers(
psych350data::superman,
var1 = "type",
var2 = "tomatometer",
var1_labels = c("Film", "TV Show", "Serial")
)
# Access omnibus chi-square and pairwise comparisons
result$ChiSquare
result$Pairwisek-Group Chi-Square Test with Pairwise Comparisons
Description
Performs a chi-square test of independence on two categorical variables where var1 has 3+ levels and var2 has exactly 2 levels, then conducts all pairwise chi-square comparisons with effect sizes. All numeric values stored unrounded.
Usage
chi_square_kgroup_answers(
data,
var1,
var2,
var1_labels = NULL,
var2_labels = NULL,
pct_var2_level = 2
)
Arguments
data
|
A data frame or tibble. |
var1
|
Character string. Name of the multi-level categorical variable (rows). |
var2
|
Character string. Name of the binary categorical variable (columns). |
var1_labels
|
Character vector or NULL. Display labels for var1 levels. |
var2_labels
|
Character vector or NULL. Display labels for var2 levels. |
pct_var2_level
|
Integer. Which level of var2 to use for percentage comparisons (1 or 2). Default is 2. |
Value
A list with elements (all numeric values unrounded).