calc_binomial_test: Perform a Binomial Test Using a Categorical Variable

View source: R/calc_binomial_test.R

calc_binomial_testR Documentation

Perform a Binomial Test Using a Categorical Variable

Description

Perform a Binomial Test Using a Categorical Variable

Usage

calc_binomial_test(
  data,
  var,
  success_value = NULL,
  p_null = 0.5,
  alternative = c("two.sided", "less", "greater"),
  conf_level = 0.95
)

Arguments

data

A tibble or data frame containing the data.

var

The categorical variable to test.

success_value

(Optional) The value considered as "success" in the binomial test.

p_null

The hypothesized probability of success under the null hypothesis (default = 0.5).

alternative

The alternative hypothesis: "two.sided", "less", or "greater".

conf_level

The confidence level for the interval (default = 0.95).

Value

A tibble containing the binomial test results, including:

  • x: Number of successes.

  • n: Total trials.

  • estimate: Observed success proportion.

  • lower_ci: Lower confidence interval.

  • upper_ci: Upper confidence interval.

  • p_value: p-value for the test.

  • p_null: Null hypothesis proportion.

  • success_value: The value considered as success.

Examples

library(tibble)

mice_data <- tibble(
  mouse_id = 1:160,
  sex = c(rep("Male", 95), rep("Female", 65)),
  cancer_status = rep("Cancer", 160)
)

calc_binomial_test(data = mice_data, var = sex)

emilelatour/lamisc documentation built on March 29, 2025, 1:23 p.m.