srh.kway: K-way SRH on ranks with tie-corrected p-values and rank-based...

View source: R/srh.kway.R

srh.kwayR Documentation

K-way SRH on ranks with tie-corrected p-values and rank-based effect sizes

Description

Generalizes the Scheirer–Ray–Hare (SRH) approach to k-factor designs by using Type II sums of squares from a linear model on ranks, with a standard tie correction D applied to p-values. The function returns H, tie-corrected H (Hadj), p-values and rank-based effect sizes (eta2H, eps2H) for each main effect and interaction up to the full order (i.e., (A + B + ...)^k).

Usage

srh.kway(formula, data, clamp0 = TRUE, force_factors = TRUE, ...)

Arguments

formula

A formula of the form y ~ A + B (+ C ...).

data

A data.frame with the variables in formula.

clamp0

Logical; if TRUE (default), negative eta2H is truncated to 0 and eps2H truncated to the interval [0, 1].

force_factors

Logical; coerce grouping variables to factor (default TRUE).

...

Passed to stats::lm() if applicable.

Details

Ranks are computed globally on y (ties.method = "average"). Type II sums of squares are obtained from car::Anova(fit, type = 2) on the rank model R ~ (A + B + ...)^k. The tie correction is

D = 1 - \frac{\sum (t^3 - t)}{n^3 - n},

where t are tie block sizes and n is the number of complete cases. We report Hadj = H / D and p = P(\chi^2_{df} \ge Hadj).

Rank-based effect sizes are computed from the uncorrected H (classical SRH convention):

  • eta2H = (H - k + 1) / (n - k), where k is the number of groups compared by the term (for interactions, the number of observed combinations),

  • eps2H = H * (n + 1) / (n^2 - 1) (KW-like epsilon squared).

Value

A data.frame with class c("srh_kway","anova","data.frame") containing columns: Effect, Df, Sum Sq, H, Hadj, p.chisq, k, n, eta2H, eps2H. The original call is attached as an attribute and can be retrieved with getCall().

Examples

data(mimicry, package = "factorH")
# One factor (KW-style check)
srh.kway(liking ~ condition, data = mimicry)

# Two factors
srh.kway(liking ~ gender + condition, data = mimicry)

# Three factors
srh.kway(liking ~ gender + condition + age_cat, data = mimicry)


factorH documentation built on Sept. 11, 2025, 9:09 a.m.