| TukeyTest | R Documentation |
Performs Tukey's Honest Significant Difference (HSD) test for all pairwise comparisons after fitting an ANOVA model. This post hoc method uses the studentized range distribution and is appropriate when variances are equal across groups and observations are independent.
TukeyTest(modelo, comparar = NULL, alpha = 0.05)
modelo |
An |
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., |
alpha |
Significance level (default 0.05). |
Tukey's test controls the family-wise error rate and is widely used when group comparisons have not been planned in advance.
Advantages: - Strong control of Type I error rate. - Ideal for balanced designs with equal variances.
Disadvantages: - Assumes equal variances and sample sizes. - Less powerful with heteroscedasticity.
An object of class "tukey" and "comparaciones" containing:
Resultados: a data.frame with columns Comparacion, Diferencia, SE, t_value,
p_value (unadjusted), p_ajustada (Tukey), 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: "Tukey test".
Termino: the term being compared (e.g., "A", "B", or "A:B").
MSerror, df_error, N: useful for plots with error bars.
Tukey, J. W. (1949). "Comparing individual means in the analysis of variance." Biometrics, 5(2), 99–114. <https://doi.org/10.2307/3001913>
#Caso DCA
data(d_e, package = "Analitica")
mod1 <- aov(Sueldo_actual ~ as.factor(labor), data = d_e)
summary(mod1)
resultado <- TukeyTest(mod1)
summary(resultado)
plot(resultado)
#Caso DBA
mod2 <- aov(Sueldo_actual ~ as.factor(labor) + Sexo, data = d_e)
summary(mod2)
# Comparar niveles de 'tratamiento' (ajustando el error por el modelo con bloque)
res <- TukeyTest(mod2, comparar = "as.factor(labor)")
summary(res)
plot(res)
#Caso DFA Two Ways
mod3 <- aov(Sueldo_actual ~ as.factor(labor) * Sexo, data = d_e)
summary(mod3)
# promedios de as.factor(labor) (promediando sobre B)
resA <- TukeyTest(mod3, comparar = "as.factor(labor)")
summary(resA)
plot(resA)
# promedios de la interaccion entre factor A y factor B
resB <- TukeyTest(mod3, comparar = c("as.factor(labor)","Sexo"))
summary(resB)
plot(resB)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.