| Title: | Reduce Compact Letter Displays |
|---|---|
| Description: | Reduces compact letter displays (CLDs) of all pairwise comparisons. A CLD gives two groups a common letter exactly when they are not significantly different. The package finds a display with the fewest letter assignments or distinct letters that keeps every relationship. The optional CLD-sigma objective is the assignment-minimum clique covering problem of Ennis, Fayle, and Ennis (2012) <doi:10.1145/2133803.2275596>, solved as a mixed-integer linear program with 'HiGHS'. The default CLD-C method selects full maximal cliques with the fewest letters. Among displays with the selected minimum objective, it returns one fixed canonical display, so the result does not depend on the solver. The package includes the wheat yield example of Piepho (2004) <doi:10.1198/1061860043515>. |
| Authors: | John Ennis [aut, cre], Aigora [cph, fnd] |
| Maintainer: | John Ennis <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.5 |
| Built: | 2026-10-22 10:27:03 UTC |
| Source: | https://github.com/aigorahub/cld-reducer |
All 190 pairwise comparisons of 20 wheat treatments (varieties) from the
CIMMYT multi-environment yield trial analyzed by Piepho (2004) and reproduced
in Table VIII of Ennis, Fayle, and Ennis (2012). The comparisons are
"not significantly different" for 172 pairs. The standard (maximal) display
has 4 letters and 56 letter assignments. The default CLD-C result has
the same counts. With method = "assignment_minimum", reduce_letters()
returns the CLD-sigma result with 4 letters and 44 assignments.
piepho2004_wheatpiepho2004_wheat
A data frame with 190 rows and 3 columns:
Label of the first treatment, a character string from "1"
to "20".
Label of the second treatment.
Logical. TRUE when the two treatments differ
significantly.
Piepho, H.-P. (2004). An algorithm for a letter-based representation of all-pairwise comparisons. Journal of Computational and Graphical Statistics, 13(2), 456-466. doi:10.1198/1061860043515, as tabulated in Ennis, Fayle, and Ennis (2012), Table VIII. doi:10.1145/2133803.2275596
dim(piepho2004_wheat) mean(!piepho2004_wheat$significant) reduce_letters(piepho2004_wheat)$stats$assignments_after reduce_letters(piepho2004_wheat, method = "assignment_minimum")$stats$assignments_afterdim(piepho2004_wheat) mean(!piepho2004_wheat$significant) reduce_letters(piepho2004_wheat)$stats$assignments_after reduce_letters(piepho2004_wheat, method = "assignment_minimum")$stats$assignments_after
reduce_letters() and reduce_from_adjacency() find a compact letter
display (CLD) minimizing distinct letters (CLD-C, the default) or
assignments (CLD-sigma), in which two groups share a
letter exactly when they are not significantly different. The optional
CLD-sigma method solves the assignment-minimum clique covering problem of
Ennis, Fayle, and Ennis (2012). Both methods certify the essential cover when
it proves the unique optimum. 'HiGHS' solves the remaining cases.
When several displays have the same minimum objective, the function returns
the canonical one
defined in the specification (docs/algorithm.md in the source repository),
so the result does not depend on the solver. The same method is available
in Python and JavaScript, and all three return the same display.
reduce_letters( pairs, means = NULL, group1 = "group1", group2 = "group2", significant = "significant", method = "letter_minimum", time_limit = NULL, max_cliques = 10000L ) reduce_from_adjacency( adjacency, groups = NULL, means = NULL, method = "letter_minimum", time_limit = NULL, max_cliques = 10000L )reduce_letters( pairs, means = NULL, group1 = "group1", group2 = "group2", significant = "significant", method = "letter_minimum", time_limit = NULL, max_cliques = 10000L ) reduce_from_adjacency( adjacency, groups = NULL, means = NULL, method = "letter_minimum", time_limit = NULL, max_cliques = 10000L )
pairs |
A data frame with one row for every pair of groups. The columns
named by |
means |
Optional group means, used for the order of the letters (the
letter that holds the highest mean comes first). Either a named numeric
vector, or a data frame with the columns |
group1, group2, significant
|
Names of the columns of |
method |
|
time_limit |
One time budget in seconds for the essential scan,
certificate checks, and all solves of the call, or
|
max_cliques |
The largest number of maximal cliques to enumerate before
stopping with an error, or |
adjacency |
A square logical or 0/1 matrix. |
groups |
Group labels for the rows of |
An object of class cld_reduction, a list with
letters: a named character vector with the display of each group
(the letters of a group are joined with no separator when every letter is
one character, and with spaces after Z, when letters like "AA" appear);
assignments: a named list with the letters of each group as a character
vector;
stats: a list with assignments_before, assignments_after,
reduction_pct (not rounded), num_letters_before, num_letters_after,
num_groups, num_edges, solver_status, and objective;
method, groups, relationship_preserved, and adjacency (a logical
matrix).
objective equals assignments_after for CLD-sigma and num_letters_after
for CLD-C. For a staged method it is the second count: assignments_after
for "letter_then_assignment" and num_letters_after for
"assignment_then_letter". assignments_after and reduction_pct always measure assignments.
Equal C optima select the lexicographically greatest binary clique vector
in canonical order, then use the same stable mean/index letter formatting.
The print() method shows the display and the counts, and
as.data.frame() gives a table with the columns group, letters, and
assignments.
Malformed input stops with a condition of class cldreducer_invalid_input.
Solver problems, an invalid time_limit or max_cliques, and too many
cliques stop with a condition of class cldreducer_solver_error. Both also
have the class cldreducer_error.
Ennis, J. M., Fayle, C. M., and Ennis, D. M. (2012). Assignment-minimum clique coverings. ACM Journal of Experimental Algorithmics, 17, Article 1.5. doi:10.1145/2133803.2275596
# Five groups; groups 1 to 3, 2 to 4, and 3 to 5 do not differ. result <- reduce_letters(simple_abc_pairs, simple_abc_means) result$letters result$stats$assignments_after # The same example from the matrix of non-significant pairs adjacency <- diag(TRUE, 5) adjacency[cbind(c(1, 1, 2, 2, 3, 3, 4), c(2, 3, 3, 4, 4, 5, 5))] <- TRUE adjacency <- adjacency | t(adjacency) reduce_from_adjacency(adjacency, means = simple_abc_means)# Five groups; groups 1 to 3, 2 to 4, and 3 to 5 do not differ. result <- reduce_letters(simple_abc_pairs, simple_abc_means) result$letters result$stats$assignments_after # The same example from the matrix of non-significant pairs adjacency <- diag(TRUE, 5) adjacency[cbind(c(1, 1, 2, 2, 3, 3, 4), c(2, 3, 3, 4, 4, 5, 5))] <- TRUE adjacency <- adjacency | t(adjacency) reduce_from_adjacency(adjacency, means = simple_abc_means)
The group means that go with simple_abc_pairs. They fix the order of the groups and of the letters.
simple_abc_meanssimple_abc_means
A data frame with 5 rows and 2 columns: group (character labels
"1" to "5") and mean (numeric).
Ennis, J. M., Fayle, C. M., and Ennis, D. M. (2012). Assignment-minimum clique coverings. ACM Journal of Experimental Algorithmics, 17, Article 1.5. doi:10.1145/2133803.2275596
simple_abc_pairs, reduce_letters()
simple_abc_meanssimple_abc_means
The five-group example of Ennis, Fayle, and Ennis (2012) in which the
CLD-sigma method reduces the display ABC of one group to AC.
The default CLD-C result keeps ABC. Groups 1 to 3, 2 to 4,
and 3 to 5 do not differ significantly; all other pairs do.
simple_abc_pairssimple_abc_pairs
A data frame with 10 rows and 3 columns: group1 and group2
(character labels "1" to "5") and significant (logical).
Ennis, J. M., Fayle, C. M., and Ennis, D. M. (2012). Assignment-minimum clique coverings. ACM Journal of Experimental Algorithmics, 17, Article 1.5. doi:10.1145/2133803.2275596
simple_abc_means, reduce_letters()
simple_abc_pairs reduce_letters(simple_abc_pairs, simple_abc_means)$letters reduce_letters(simple_abc_pairs, simple_abc_means, method = "assignment_minimum")$letterssimple_abc_pairs reduce_letters(simple_abc_pairs, simple_abc_means)$letters reduce_letters(simple_abc_pairs, simple_abc_means, method = "assignment_minimum")$letters