SNKTest: Student-Newman-Keuls (SNK) Test for Multiple Comparisons v2.0

View source: R/SNKTest.R

SNKTestR Documentation

Student-Newman-Keuls (SNK) Test for Multiple Comparisons v2.0

Description

Performs the Student-Newman-Keuls (SNK) post hoc test for pairwise comparisons after fitting an ANOVA model. The test uses a stepwise approach where the critical value depends on the number of means spanned between groups (range r).

Usage

SNKTest(modelo, comparar = NULL, alpha = 0.05)

Arguments

modelo

An aov or lm object (full model: includes blocks, factors, etc.).

comparar

Character vector with the name(s) of the factor(s) to compare: - One name: main effect (e.g., "treatment" or "A") - Several names: interaction (e.g., c("A","B") for A:B) If omitted, it uses the first factor in modelo$xlevels.

alpha

Significance level (default 0.05).

Details

SNK is more powerful but less conservative than Tukey’s HSD, increasing the chance of detecting real differences while slightly raising the Type I error rate.

Assumptions: normality, homogeneity of variances, and independence of observations.

Advantages: - More powerful than Tukey when differences are large. - Intermediate control of Type I error.

Disadvantages: - Error control is not family-wise. - Type I error increases with more comparisons.

Value

An object of class "SNK" and "comparaciones" containing:

  • Resultados: a data.frame with columns Comparacion, Diferencia, SE, t_value, p_value (unadjusted), p_ajustada (SNK), Valor_Critico (critical difference), and Significancia.

  • Promedios: a named vector of group means as defined by comparar.

  • Orden_Medias: group names ordered from highest to lowest mean.

  • Metodo: "SNK t-test".

  • Termino: the term being compared (e.g., "A", "B", or "A:B").

  • MSerror, df_error, N: useful for plots with error bars.

References

Student, Newman, and Keuls (1952). "Student-Newman-Keuls Procedure". See also: <https://doi.org/10.1002/bimj.200310019>

Examples

data(d_e, package = "Analitica")
mod <- aov(Sueldo_actual ~ as.factor(labor), data = d_e)
resultado <- SNKTest(mod)
summary(resultado)
plot(resultado)

# RCBD
mod <- aov(Sueldo_actual ~ as.factor(labor) + Sexo, data = d_e)
res <- SNKTest(mod, comparar = "as.factor(labor)")
summary(res); plot(res)                      # plot usara p_value

# Factorial
mod2 <- aov(Sueldo_actual ~ as.factor(labor) * Sexo, data = d_e)
resAB <- SNKTest(mod2, comparar = c("as.factor(labor)","Sexo"))
summary(resAB, n = Inf); plot(resAB, horizontal = TRUE)


Analitica documentation built on Nov. 5, 2025, 5:13 p.m.