Learn R Programming

trendtestR (version 1.0.1)

run_paired_tests: Paired / Unpaired Two-Group Tests with Assumption Checks / Zwei-Gruppen-Test mit Vorannahmepruefung

Description

This function performs both parametric (t-test) and non-parametric (Wilcoxon test) comparisons between two groups. For paired data, it calculates the difference and performs Shapiro-Wilk normality test on the difference. Based on this, it recommends either a paired t-test or a Wilcoxon signed-rank test. Optionally, it calculates the effect size (Cohen's d) and returns assumption diagnostics.

Usage

run_paired_tests(
  df,
  value_col = ".value",
  group_col = "jahr",
  alpha = 0.05,
  effect_size = TRUE,
  report_assumptions = TRUE,
  paired = TRUE
)

Value

A list containing:

type

Test type performed ("Paired Test" or "Unpaired Test")

sample_sizes

Number of observations per group

group_names

Names of the two groups

t_test

Result of the t-test (paired or unpaired)

wilcox_test

Result of the Wilcoxon test

effect_size

Cohen's d (if enabled)

assumptions

Shapiro-Wilk normality test result(s)

recommendation

Recommended test based on normality

Arguments

df

A data frame with exactly two groups. / Ein Data Frame mit genau zwei Gruppen

value_col

Name of the column containing values to compare. Default is ".value". / Name der Werte-Spalte, Standard: ".value"

group_col

Name of the grouping variable. Default is "jahr". / Spaltenname der Gruppierungsvariable, Standard: "jahr"

alpha

Significance level for hypothesis testing. Default is 0.05. / Signifikanzniveau fuer Testentscheidungen, Standard: 0.05

effect_size

Logical. Whether to calculate Cohen's d. / Logisch, ob Cohen's d berechnet werden soll

report_assumptions

Logical. Whether to include normality test results. / Logisch, ob Shapiro-Test zurueckgegeben wird

paired

Logical. Whether the data are paired. / Logisch: gepaarte Daten?

Details

Diese Funktion fuehrt sowohl parametrische (t-Test) als auch nicht-parametrische (Wilcoxon-Test) Vergleiche zwischen zwei Gruppen durch. Bei gepaarten Daten wird die Differenz gebildet und auf Normalverteilung geprueft(Shapiro-Test). Je nach Ergebnis wird ein gepaarter t-Test oder ein Wilcoxon-Vorzeichen-Rang-Test empfohlen. Optional wird die Effektgroesse (Cohens d) berechnet und die Vorannahmen zurueckgegeben.

See Also

[run_group_tests()], [run_multi_group_tests()], [prepare_group_data()]

Examples

Run this code
df <- data.frame(
  jahr = rep(c("2020", "2021"), each = 10),
  .value = c(rnorm(10, 30), rnorm(10, 32))
)
run_paired_tests(df, paired = TRUE)

Run the code above in your browser using DataLab