Learn R Programming

trendtestR (version 1.0.1)

run_count_multi_group_tests: Statistical Test for Count Data (Multi-Groups) / Statistischer Test fuer Zaehldaten (Mehrere Gruppen)

Description

This function performs a simple comparison of count data across three or more groups. It uses Poisson or Negative Binomial regression, considering overdispersion, followed by an ANOVA-like test for the overall group effect and optional post-hoc tests. Focus is on overall p-value and identifying differing groups, without complex model interpretation.

Usage

run_count_multi_group_tests(
  df,
  value_col = ".value",
  group_col = "jahr",
  alpha = 0.05,
  phi = 1.5,
  effect_size = FALSE,
  report_assumptions = FALSE
)

Value

A list containing test results (p-value, significant groups, chosen method).

Arguments

df

A data frame containing the data, already prepared (e.g., by prepare_group_data).

value_col

Name of the column containing count values. Default is ".value".

group_col

Name of the grouping variable. Default is "jahr".

alpha

Significance level for hypothesis testing. Default is 0.05.

phi

Common heuristic for overdispersion. Default is 1.5.

effect_size

Logical. Whether to calculate and return a simple effect size (e.g., Pseudo R-squared).

report_assumptions

Logical. Whether to report basic assumption diagnostics (e.g., overdispersion status).

Details

Diese Funktion fuehrt einen einfachen Vergleich von Zaehldaten bei drei oder mehr Gruppen durch. Sie verwendet Poisson- oder Negative Binomial-Regression (abhaengig von Ueberdispersion), gefolgt von einem ANOVA-aehnlichen Test fuer den Gesamtgruppeneffekt und optionalen Post-Hoc-Tests. Der Schwerpunkt liegt auf dem Gesamt-p-Wert und der Identifizierung unterschiedlicher Gruppen, ohne komplexe Modellinterpretation.

Examples

Run this code
set.seed(123)
data <- data.frame(
.value = c(rpois(50, 3), rpois(50, 5), rpois(50, 4)),
jahr = factor(rep(c("2020", "2021", "2022"), each = 50))
)

result <- run_count_multi_group_tests(
df = data,
value_col = ".value",
group_col = "jahr",
alpha = 0.05,
phi = 1.5,
effect_size = TRUE,
report_assumptions = TRUE
)

print(result$p_value)
print(result$significant_pairwise_differences)
print(result$effect_size)

Run the code above in your browser using DataLab