Tukey's Honestly Significant Difference (HSD) Post-Hoc Mean Comparison Engine
compute_tukey.RdThe `compute_tukey` function executes a high-precision pairwise post-hoc mean separation analysis using Tukey's Honestly Significant Difference framework.
Usage
compute_tukey(
data,
trait,
anova_results,
total_replications,
alpha = 0.05,
reporting_level = 2
)Arguments
- data
A verified
data.framecontaining the columnsGenotypeand the phenotypic trait under evaluation.- trait
A single character string specifying the column name of the target trait.
- anova_results
A structured
listderived from upstream ANOVA layouts.- total_replications
An integer specifying the absolute number of replication blocks (\(r\)).
- alpha
A numeric value defining the adjusted family-wise error rate threshold. Defaults to
0.05.- reporting_level
An integer vector flag defining console trace settings. Defaults to
2.
Value
A structured named list of class "list" containing 4 computational components:
- tukey_value
The absolute calculated scalar value of Tukey's Honestly Significant Difference threshold.
- se_mean
The isolated Standard Error of the treatment mean scalar (\(SE_{\bar{y}}\)).
- comparison_matrix
A detailed data frame or
NULLlayout reserved for pairwise lines differences.- ranked_means
A structured data frame containing sorted treatment means and significance group letters (
Tukey_Letters).
Author
Faheem Khan (2022ag94@uaf.edu.pk)
Examples
data(gv_data, package = "AgriDataTools")
reps <- length(unique(gv_data$Replication))
model_fit <- aov(PH ~ Genotype + Replication, data = gv_data)
anova_summary <- summary(model_fit)[[1]]
mock_anova <- list(
anova_table = data.frame(
Source = c("Genotype", "Replication", "Error"),
Df = anova_summary$Df,
MS = anova_summary$`Mean Sq`,
stringsAsFactors = FALSE
)
)
tukey_output <- compute_tukey(
data = gv_data,
trait = "PH",
anova_results = mock_anova,
total_replications = reps
)
print(tukey_output$ranked_means)
#> Genotype Mean Tukey_Letters
#> 1 G16 103.66667 a
#> 2 G7 100.83333 ab
#> 3 G3 100.66667 abc
#> 4 G25 99.66667 abcd
#> 5 G27 99.66667 abcd
#> 6 G9 99.16667 abcd
#> 7 G2 97.50000 abcde
#> 8 G20 97.30000 abcde
#> 9 G11 96.66667 abcdef
#> 10 G13 96.33333 abcdef
#> 11 G18 95.33333 bcdefg
#> 12 G14 95.00000 bcdefgh
#> 13 G23 95.00000 bcdefgh
#> 14 G5 94.33333 bcdefgh
#> 15 G29 93.66667 bcdefgh
#> 16 G31 93.66667 bcdefgh
#> 17 G33 93.50000 bcdefgh
#> 18 G21 93.33333 bcdefgh
#> 19 G1 92.66667 cdefghi
#> 20 G22 92.66667 cdefghi
#> 21 G38 92.66667 cdefghi
#> 22 G26 92.33333 defghij
#> 23 G8 92.00000 defghij
#> 24 G15 91.83333 defghij
#> 25 G17 91.66667 defghij
#> 26 G30 91.66667 defghij
#> 27 G40 91.66667 defghij
#> 28 G37 91.00000 efghij
#> 29 G24 90.50000 efghij
#> 30 G4 90.50000 efghij
#> 31 G6 89.83333 efghij
#> 32 G39 89.66667 efghij
#> 33 G32 89.00000 fghij
#> 34 G36 89.00000 fghij
#> 35 G19 87.66667 ghij
#> 36 G12 87.33333 ghij
#> 37 G34 87.33333 ghij
#> 38 G10 87.00000 hij
#> 39 G28 84.83333 ij
#> 40 G35 84.33333 j