| 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 that keeps every one of these relationships. This 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'. Among the displays with the fewest assignments, 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.2.0 |
| Built: | 2026-10-21 20:56:06 UTC |
| Source: | https://github.com/cran/cldreducer |
All 190 pairwise comparisons of 20 wheat treatments (varieties) from the
CIMMYT multi-environment yield trial analyzed by Piepho (2004) and reproduced
in Table 7 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 reduced display from
reduce_letters() also has 4 letters, but only 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 7. doi:10.1145/2133803.2275596
dim(piepho2004_wheat) mean(!piepho2004_wheat$significant)dim(piepho2004_wheat) mean(!piepho2004_wheat$significant)
reduce_letters() and reduce_from_adjacency() find a compact letter
display (CLD) with the fewest letter assignments in which two groups share a
letter exactly when they are not significantly different. This is the
assignment-minimum clique covering problem of Ennis, Fayle, and Ennis
(2012). The programs are solved with 'HiGHS'. When several displays have the
same, smallest number of assignments, 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 = "assignment_minimum", time_limit = NULL, max_cliques = 10000L ) reduce_from_adjacency( adjacency, groups = NULL, means = NULL, method = "assignment_minimum", time_limit = NULL, max_cliques = 10000L )reduce_letters( pairs, means = NULL, group1 = "group1", group2 = "group2", significant = "significant", method = "assignment_minimum", time_limit = NULL, max_cliques = 10000L ) reduce_from_adjacency( adjacency, groups = NULL, means = NULL, method = "assignment_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 |
The reduction method. |
time_limit |
One time budget in seconds for 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).
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
standard display ABC of one group reduces to AC. 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)$letterssimple_abc_pairs reduce_letters(simple_abc_pairs, simple_abc_means)$letters