chi_squared_test: Chi-squared test

View source: R/chi_squared_test.R

chi_squared_testR Documentation

Chi-squared test

Description

Conduct a chi-squared test and produce a contingency table

Usage

chi_squared_test(
  data = NULL,
  iv_name = NULL,
  dv_name = NULL,
  round_chi_sq_test_stat = 2,
  round_p = 3,
  sigfigs_proportion = 2,
  correct = TRUE,
  odds_ratio_ci = 0.95,
  round_odds_ratio_ci_limits = 2,
  invert = FALSE
)

Arguments

data

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

iv_name

name of the independent variable

dv_name

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

round_chi_sq_test_stat

number of decimal places to which to round the chi-squared test statistic (default = 2)

round_p

number of decimal places to which to round the p-value from the chi-squared test (default = 3)

sigfigs_proportion

number of significant digits to round to (for the table of proportions). By default sigfigs_proportion = 2

correct

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

odds_ratio_ci

width of the confidence interval for the odds ratio. Input can be any value less than 1 and greater than or equal to 0. By default, odds_ratio_ci = 0.95. If odds_ratio_ci = TRUE, the default value of 0.95 will be used. If odds_ratio_ci = FALSE, no confidence interval will be estimated for the odds ratio.

round_odds_ratio_ci_limits

number of decimal places to which to round the limits of the odds ratio's confidence interval (default = 2)

invert

logical. Whether the inverse of the odds ratio (i.e., 1 / odds ratio) should be returned.

Examples

chi_squared_test(data = mtcars, iv_name = "cyl", dv_name = "am")
# if the iv has only two levels, odds ratio will also be calculated
chi_squared_test(data = mtcars, iv_name = "vs", dv_name = "am")

kim documentation built on Oct. 9, 2023, 5:08 p.m.