Skip to content

TukeyHSD: No method to get group1 and group2 to match res.std_pairs #2762

Closed

Description

@trevstanhope

I wanted to write a function to export the TukeyHSDResult to a CSV file, however there doesn't seem to be any rhyme or reason to the output from res.groups...

Using res.groupsunique I can calculate the combinations possible (e.g. for 6 groups I know there should be 15 unique combinations which corresponds to the len(res.std_pairs) as well as the summary output) but when I call res.groups I get a list of 52 strings, with each group label repeated several times. I would understand if it was double in length of the combinations, or even double in length plus the redundant A --> A (or A <-- A) comparisons, but even then I would expect the length of the list to be 42, not 52

What logic is producing the strange behavior of res.groups? Has anyone already come up with a function which I can use to produce a proper length list, e.g. of tuples like (group1_label, group2_label) ?

Activity

  1. josef-pkt commented on Jan 15, 2016

    @josef-pkt
    Member

    Do you or do we have an example that shows this?
    how many observations do you have?
    Maybe groups contain the labels for each observation.

  2. trevstanhope commented on Jan 16, 2016

    @trevstanhope
    Author

    Here is the what I was working with for testing:

    test.zip

  3. josef-pkt commented on Mar 5, 2016

    @josef-pkt
    Member

    It looks like the group pairs are never attached, i.e. go out of scope after creating summary table

    here's the info from the summary table, first two columns

    >>> [(row[0].data, row[1].data) for row in res_reduced._results_table]
    [('group1', 'group2'), ('cv-10-15', 'cv-<10'), ('cv-10-15', 'cv->15'), ('cv-10-15', 'rods-10-15'), ('cv-10-15', 'rods-<10'), ('cv-10-15', 'rods->15'), ('cv-<10', 'cv->15'), ('cv-<10', 'rods-10-15'), ('cv-<10', 'rods-<10'), ('cv-<10', 'rods->15'), ('cv->15', 'rods-10-15'), ('cv->15', 'rods-<10'), ('cv->15', 'rods->15'), ('rods-10-15', 'rods-<10'), ('rods-10-15', 'rods->15'), ('rods-<10', 'rods->15')]
    
  4. josef-pkt commented on Mar 5, 2016

    @josef-pkt
    Member

    the simultaneous_ci function gets the information out of the attached _multicomp which has the pairindices

    >>> res_reduced.groupsunique[res_reduced._multicomp.pairindices[0]]
    array([cv-10-15, cv-10-15, cv-10-15, cv-10-15, cv-10-15, cv-<10, cv-<10,
           cv-<10, cv-<10, cv->15, cv->15, cv->15, rods-10-15, rods-10-15,
           rods-<10], dtype=object)
    >>> res_reduced.groupsunique[res_reduced._multicomp.pairindices[1]]
    array([cv-<10, cv->15, rods-10-15, rods-<10, rods->15, cv->15, rods-10-15,
           rods-<10, rods->15, rods-10-15, rods-<10, rods->15, rods-<10,
           rods->15, rods->15], dtype=object)
    

    or fancy indexing

    >>> res_reduced.groupsunique[np.column_stack(res_reduced._multicomp.pairindices)]
    array([[cv-10-15, cv-<10],
           [cv-10-15, cv->15],
           [cv-10-15, rods-10-15],
           [cv-10-15, rods-<10],
           [cv-10-15, rods->15],
           [cv-<10, cv->15],
           [cv-<10, rods-10-15],
           [cv-<10, rods-<10],
           [cv-<10, rods->15],
           [cv->15, rods-10-15],
           [cv->15, rods-<10],
           [cv->15, rods->15],
           [rods-10-15, rods-<10],
           [rods-10-15, rods->15],
           [rods-<10, rods->15]], dtype=object)
    
  5. added this to the 0.15 milestone on Jan 25, 2025
  6. josef-pkt commented on Jan 25, 2025

    @josef-pkt
    Member

    #9487 added group_t and group_c attributes with group names
    see PR why I did not use group1 and group2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions