chisq_test: Perform Chi-Square Test on Sets of Transmission Trees

View source: R/chisq_test.R

chisq_testR Documentation

Perform Chi-Square Test on Sets of Transmission Trees

Description

Tests whether the distribution of infector-infectee pairs differs between sets of transmission trees.

Usage

chisq_test(..., method = c("chisq", "fisher"), test_args = list())

Arguments

...

Two or more sets of transmission trees. Each set is a list of data frames with columns from and to.

method

Test to use: "chisq" for Chi-Square or "fisher" for Fisher's Exact Test. Default is "chisq".

test_args

A list of additional arguments for stats::chisq.test or stats::fisher.test. Default is an empty list.

Value

An htest object with the test results.

Examples

set.seed(1)
# No difference in the sets
setA <- replicate(10, igraph::as_long_data_frame(
  make_tree(n_cases = 10, R = 2, stochastic = TRUE)
),
simplify = FALSE
)
setB <- replicate(10, igraph::as_long_data_frame(
  make_tree(n_cases = 10, R = 2, stochastic = TRUE)
),
simplify = FALSE
)
chisq_test(setA, setB)

# Difference in the sets
setC <- replicate(10, igraph::as_long_data_frame(
  make_tree(n_cases = 10, R = 4, stochastic = TRUE)
),
simplify = FALSE
)
chisq_test(setA, setB, setC)

mixtree documentation built on April 3, 2025, 8:01 p.m.