Fisher's Least Significant Difference (LSD) Post-Hoc Mean Comparison Engine
compute_lsd.RdThe `compute_lsd` function executes a rigorous, high-precision pairwise post-hoc mean separation analysis using Fisher's Least Significant Difference protocol. It isolates critical differences, evaluates pairwise significance metrics, and outputs comprehensive ranking tables with group letters.
Usage
compute_lsd(
data,
trait,
anova_results,
total_replications,
alpha = 0.05,
reporting_level = 2
)Arguments
- data
A verified
data.framecontaining the columnsGenotypeand the phenotypic trait under investigation.- trait
A single character string specifying the column name of the target trait.
- anova_results
A structured
listderived from upstream ANOVA layouts containing ananova_table.- total_replications
An integer specifying the absolute number of replication blocks (\(r\)).
- alpha
A numeric value defining the Type-I error rate probability threshold. Defaults to
0.05.- reporting_level
An integer vector flag defining console trace settings:
0for silent execution,1for summary, and2for exhaustive tracking. Defaults to2.
Value
A structured named list of class "list" containing 4 computational components:
- lsd_value
A numeric scalar representing the absolute calculated value of Fisher's Least Significant Difference at the specified alpha level.
- sed
A numeric scalar representing the isolated Standard Error of Difference (SED) between two treatment means.
- comparison_matrix
A
data.frameorNULLlayout reserved for detailed pairwise lines differences.- ranked_means
A
data.framecontaining lines/cultivars sorted by mean performance alongside their assigned statistical significance group letters (LSD_Letters).
Examples
# Load integrated data matrices
data(gv_data, package = "AgriDataTools")
# Total replications matching the experimental design blocks
reps <- length(unique(gv_data$Replication))
# Generating upstream ANOVA structure from gv_data for the target trait (PH)
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
)
)
# Running post-hoc separation sweeps with clean letters group layout
lsd_output <- compute_lsd(
data = gv_data,
trait = "PH",
anova_results = mock_anova,
total_replications = reps,
alpha = 0.05
)
print(lsd_output$ranked_means)
#> Genotype Mean LSD_Letters
#> 1 G16 103.66667 a
#> 2 G7 100.83333 ab
#> 3 G3 100.66667 ab
#> 4 G25 99.66667 bc
#> 5 G27 99.66667 bc
#> 6 G9 99.16667 bcd
#> 7 G2 97.50000 bcde
#> 8 G20 97.30000 bcdef
#> 9 G11 96.66667 cdefg
#> 10 G13 96.33333 cdefgh
#> 11 G18 95.33333 defghi
#> 12 G14 95.00000 efghi
#> 13 G23 95.00000 efghi
#> 14 G5 94.33333 efghij
#> 15 G29 93.66667 efghijk
#> 16 G31 93.66667 efghijk
#> 17 G33 93.50000 fghijkl
#> 18 G21 93.33333 ghijkl
#> 19 G1 92.66667 hijklm
#> 20 G22 92.66667 hijklm
#> 21 G38 92.66667 hijklm
#> 22 G26 92.33333 ijklm
#> 23 G8 92.00000 ijklm
#> 24 G15 91.83333 ijklm
#> 25 G17 91.66667 ijklm
#> 26 G30 91.66667 ijklm
#> 27 G40 91.66667 ijklm
#> 28 G37 91.00000 jklmn
#> 29 G24 90.50000 jklmno
#> 30 G4 90.50000 jklmno
#> 31 G6 89.83333 klmno
#> 32 G39 89.66667 lmno
#> 33 G32 89.00000 mno
#> 34 G36 89.00000 mno
#> 35 G19 87.66667 nop
#> 36 G12 87.33333 nop
#> 37 G34 87.33333 nop
#> 38 G10 87.00000 op
#> 39 G28 84.83333 p
#> 40 G35 84.33333 p