factorH: functions reference

Function reference

This document collects call patterns and options for each public function. All formulas follow response ~ A + B (+ C …) with numeric response and factor predictors.

srh.kway.full()

Purpose: one-call pipeline: ANOVA on ranks + descriptives + post hocs + simple effects.
Syntax: srh.kway.full(y ~ A + B (+ C …), data, max_levels = 30)

Example:

res <- srh.kway.full(liking ~ gender + condition + age_cat, data = mimicry)
names(res)
res$anova[1:3]
head(res$summary)
names(res$posthoc_cells)
names(res$posthoc_simple)[1:3]
res$meta

Notes:

write.srh.kway.full.tsv()

Purpose: export the srh.kway.full() result into a single TSV file for fast formatting.
Syntax: write.srh.kway.full.tsv(obj, file = “srh_kway_full.tsv”, sep = “, na =”“, dec =”.”)

Example:

# you can of course provide your own path to the file outside the temporary folder
f <- file.path(tempdir(), "result.tsv")
write.srh.kway.full.tsv(res, file = f, dec = ",")
file.exists(f)

srh.kway()

Purpose: general k-way SRH-style ANOVA on ranks (Type II SS), tie-corrected p-values. Syntax: srh.kway(y ~ A + B (+ C …), data, clamp0 = TRUE, force_factors = TRUE, type = 2, …)

Example:

k3 <- srh.kway(liking ~ gender + condition + age_cat, data = mimicry)
k3

One-factor check (KW-like):

k1 <- srh.kway(liking ~ condition, data = mimicry)
k1

Two factor (Type III SS):

k3_ss3 <- srh.kway(liking ~ gender + condition, data = mimicry, type = 3)
k3_ss3

srh.effsize()

Purpose: 2-way SRH table with effect sizes from H.
Syntax: srh.effsize(y ~ A + B, data, clamp0 = TRUE, …)

Example:

e2 <- srh.effsize(liking ~ gender + condition, data = mimicry)
e2

nonpar.datatable()

Purpose: compact descriptive tables (APA-style), with global rank means, medians, quartiles, IQR.
Syntax: nonpar.datatable(y ~ A + B (+ C …), data, force_factors = TRUE)

Example:

dt <- nonpar.datatable(liking ~ gender + condition, data = mimicry)
head(dt)

srh.posthoc()

Purpose: Dunn–Bonferroni pairwise comparison matrix for a specified effect.
Syntax: srh.posthoc(y ~ A (+ B + …), data, method = “bonferroni”, digits = 3, triangular = c(“lower”,“upper”,“full”), numeric = FALSE, force_factors = TRUE, sep = “.”)

Example:

ph <- srh.posthoc(liking ~ condition, data = mimicry)

srh.posthocs()

Purpose: Dunn–Bonferroni pairwise matrices for all effects (main and interactions).
Syntax: srh.posthocs(y ~ A + B (+ C …), data, …)

Example:

phs <- srh.posthocs(liking ~ gender + condition + age_cat, data = mimicry)
names(phs)
phs[["gender:condition"]][1:5, 1:5]

srh.simple.posthoc()

Purpose: Simple-effects post hocs (pairwise comparisons within levels of conditioning factors).
Syntax: srh.simple.posthoc(y ~ A + B (+ C …), data, compare = NULL, scope = c(“within”,“global”), digits = 3)

Example:

simp <- srh.simple.posthoc(liking ~ gender + condition + age_cat, data = mimicry, compare = "gender", scope = "within")
head(simp)

srh.simple.posthocs()

Purpose: enumerate all simple-effect configurations for a given design.
Syntax: srh.simple.posthocs(y ~ A + B (+ C …), data)

Example:

sps <- srh.simple.posthocs(liking ~ gender + condition + age_cat, data = mimicry)
head(names(sps), 6)

normality.datatable

Purpose: Shapiro–Wilk normality tests for the raw response within each subgroup for all non-empty combinations of RHS factors (main effects and interaction cells). Syntax: normality.datatable(y ~ A + B (+ C …), data, force_factors = TRUE)

Example:

normality.datatable(liking ~ gender + condition + age_cat, data = mimicry)

residuals.normality.datatable

Purpose: Shapiro–Wilk normality tests on residuals from a classical ANOVA model fitted to the selected RHS factors (full factorial for those factors), one test per model (global residuals). Syntax: residuals.normality.datatable(y ~ A + B (+ C …), data, force_factors = TRUE)

Example:

residuals.normality.datatable(liking ~ gender + condition + age_cat, data = mimicry)

residuals.cellwise.normality.datatable

Purpose: Shapiro–Wilk tests of residuals from an ANOVA model fitted to the selected RHS factors (full factorial), but tested separately within each cell defined by those factors. Syntax: residuals.cellwise.normality.datatable(y ~ A + B (+ C …), data, force_factors = TRUE)

Example:

residuals.cellwise.normality.datatable(liking ~ gender + condition + age_cat, data = mimicry)

balance.chisq.datatable

Purpose: Count-balance diagnostics across design factors. Syntax: balance.chisq.datatable(y ~ A + B (+ C …), data, force_factors = TRUE)

Example:

balance.chisq.datatable(liking ~ gender + condition + age_cat, data = mimicry)

levene.plan.datatable

Purpose: Levene/Brown–Forsythe test for homogeneity of variances across the full-plan cells (highest-order interaction of RHS factors). Syntax: levene.plan.datatable(y ~ A + B (+ C …), data, center = “median”, force_factors = TRUE)

Examples:

levene.plan.datatable(liking ~ gender + condition + age_cat, data = mimicry)  
levene.plan.datatable(liking ~ gender + condition, data = mimicry, center = "mean")

plan.diagnostics

Purpose: Orchestrates all diagnostics in one call. Syntax: plan.diagnostics(y ~ A + B (+ C …), data, force_factors = TRUE)

Returned list:

$summary: percent_ok, ok_count, total, overall, plus per-type percentages:  
percent_ok_normality_raw, percent_ok_residuals_cellwise, percent_ok_balance_chisq, percent_ok_levene_full_plan.  
$results: normality_raw, residuals_cellwise_normality, levene_full_plan, balance_chisq.  

Examples:

diag_out <- plan.diagnostics(liking ~ gender + condition + age_cat, data = mimicry)  
diag_out$results$normality_raw  
diag_out$results$residuals_cellwise_normality  
diag_out$results$levene_full_plan  
diag_out$results$balance_chisq  
diag_out$summary

Formula tips and pitfalls

Example:

#coercing
mimicry$gender <- factor(mimicry$gender)
mimicry$condition <- factor(mimicry$condition)

Performance and reproducibility

C:116060334b62-reference.R

mirror server hosted at Truenetwork, Russian Federation.