chi_squared_test_pairwise {kim}R Documentation

Chi-squared test, pairwise

Description

Conducts a chi-squared test for every possible pairwise comparison with Bonferroni correction

Usage

chi_squared_test_pairwise(
  data = NULL,
  iv_name = NULL,
  dv_name = NULL,
  focal_dv_value = NULL,
  contingency_table = TRUE,
  contingency_table_sigfigs = 2,
  percent_and_total = FALSE,
  percentages_only = NULL,
  counts_only = NULL,
  sigfigs = 3,
  chi_sq_test_stats = FALSE,
  correct = TRUE
)

Arguments

data

a data object (a data frame or a data.table)

iv_name

name of the independent variable (must be a categorical variable)

dv_name

name of the dependent variable (must be a binary variable)

focal_dv_value

focal value of the dependent variable whose frequencies will be calculated (i.e., the value of the dependent variable that will be considered a "success" or a result of interest)

contingency_table

If contingency_table = TRUE or if contingency_table = "percentages", the percentage of each binary value within each group will be printed. If contingency_table = "counts", a table of frequencies will be printed. If contingency_table = FALSE, no contingency table will be printed.

contingency_table_sigfigs

number of significant digits that the contingency table's percentage values should be rounded to (default = 2)

percent_and_total

logical. If percent_and_total = TRUE, tabulate percentages of the focal DV value and a total count of the two values in DV. By default percent_and_total = FALSE

percentages_only

tabulate percentages of the focal DV value only

counts_only

tabulate counts of the focal DV value only

sigfigs

number of significant digits to round to

chi_sq_test_stats

if chi_sq_test_stats = TRUE, chi-squared test statistic and degrees of freedom will be included in the pairwise comparison data.table.

correct

logical. Should continuity correction be applied? (default = TRUE)

Examples

chi_squared_test_pairwise(data = mtcars, iv_name = "vs", dv_name = "am")
chi_squared_test_pairwise(data = mtcars, iv_name = "vs", dv_name = "am",
percentages_only = TRUE)
# using 3 mtcars data sets combined
chi_squared_test_pairwise(
data = rbind(mtcars, rbind(mtcars, mtcars)),
iv_name = "cyl", dv_name = "am")
# include the total counts
chi_squared_test_pairwise(
data = rbind(mtcars, rbind(mtcars, mtcars)),
iv_name = "cyl", dv_name = "am", percent_and_total = TRUE)
# display counts
chi_squared_test_pairwise(
data = rbind(mtcars, rbind(mtcars, mtcars)),
iv_name = "cyl", dv_name = "am", contingency_table = "counts")

[Package kim version 0.5.422 Index]