Skip to content

presentation of multiple comparison results #789

Closed

Description

@josef-pkt

Activity

  1. josef-pkt commented on Apr 25, 2013

    @josef-pkt
    MemberAuthor

    a case for pairwise variances in pairwise comparisons (run t_test on pairs)

    Franz, Volker H., and Geoffrey R. Loftus. 2012. “Standard Errors and Confidence Intervals in Within-subjects Designs: Generalizing Loftus and Masson (1994) and Avoiding the Biases of Alternative Accounts.” Psychonomic Bulletin & Review 19 (3) (June 1): 395–404. doi:10.3758/s13423-012-0230-1.

  2. tyleha commented on Apr 25, 2013

    @tyleha
    Contributor

    So Josef, what the results class looks like for the tukeyhsd() function is very much up to you. I have, out of necessity, added a few attrs that allow the hochberg intervals to be calculated and consolidated the returned variables to be part of the MultiComparison class itself, but not done a lot else.

    As for the 'AllPairsResults' class, it might be very useful for performing p-tests of multiple groups, but not so much for Tukey. I honestly don't know enough about statistical testing to really know how best to organize and structure this whole module, so I would gladly accept suggestions or changes from you on that front.

    My purpose has been to clean up the usage and output of the tukeyhsd method, and to create a matplotlib figure of the tukey results with single confidence intervals. As i mentioned on your blog, I'm anticipating the general use case to be:

    from statsmodels.stats.multcomp import MultiComparison
    
    data = some_numpy_vector_of_rawdata
    labels = some_numpy_vector_of_groups
    
    mc = MultiComparison(data, labels) # all tukey computations can be made on mc instance
    results_string = mc.tukeyhsd() # can print table if you want
    fig = mc.plot_tukey_intervals(groupname_to_compare_against)

    I'm not really sure what the purpose and use case of statsmodels.stats.multicomp.pairwise_tukey is -- it's just a wrapper for MultiComp.tukeyhsd() but I guess it doesn't require you to instantiate a MultiComparison instance. But then again, that could just be solved by making tukeyhsd() a classmethod...either way I think the usage in my example should be preferred, so that the MultiComparison object is created and later computations/plotting can be done using it.

    I'm going to start merging my wrapper class with the statsmodels MultiComparsion class today, will reference this issue. I'm happy for you to reorganize it however you like, I am just psyched about the tukey plotting functionality.

  3. tyleha commented on Apr 25, 2013

    @tyleha
    Contributor

    @josef-pkt, how is this looking to you? Are you ok with the general structure of things?

    The only issues I would raise with this implementation are the way in which the outputs of tukeyhsd() are stored within the MultiComparison instance. They're a little hard to get at unless you know precisely what attribute names you're looking for, or are comfortable with a little introspection.

  4. tyleha commented on Apr 25, 2013

    @tyleha
    Contributor

    If it's helpful, here's a basic dataset that shows off the functionality of MultiComparison.plot_tukeyhsd_intervals

    cylinders = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 6, 6, 6, 4, 4, 4, 4, 4, 4, 6, 8, 8, 8, 8, 4, 4, 4, 4, 4, 8, 8, 8, 8, 6, 6, 6, 6, 4, 4, 4, 4, 6, 6, 6, 6, 4, 4, 4, 4, 4, 8, 4, 6, 6, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 4, 6, 4, 4, 4, 4, 4, 4, 4, 4]
    labels = ['USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'France', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'Japan', 'USA', 'USA', 'USA', 'Japan', 'Germany', 'France', 'Germany', 'Sweden', 'Germany', 'USA', 'USA', 'USA', 'USA', 'USA', 'Italy', 'Germany', 'USA', 'USA', 'France', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'Germany', 'Japan', 'USA', 'USA', 'USA', 'USA', 'Germany', 'Japan', 'Japan', 'USA', 'Sweden', 'USA', 'France', 'Japan', 'Germany', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'Germany', 'Japan', 'Japan', 'USA', 'USA', 'Japan', 'Japan', 'Japan', 'Japan', 'Japan', 'Japan', 'USA', 'USA', 'USA', 'USA', 'Japan', 'USA', 'USA', 'USA', 'Germany', 'USA', 'USA', 'USA']
    
    carsmall = MultiComparison(cylinders, labels, group_order=['Italy', 'Sweden', 'Germany', 'Japan', 'France', 'USA'])
    cars = carsmall.tukeyhsd()
    print cars
    carsmall.plot_tukeyhsd_intervals("USA")
  5. josef-pkt commented on Apr 25, 2013

    @josef-pkt
    MemberAuthor

    the purpose and use case of statsmodels.stats.multicomp.pairwise_tukey

    two reasons I added this: one is that users have a function instead of working with a class (scipy style), the second is that it is the only part that has verified unit tests, so I was reluctant to advertise the full class

    You could open a pull request against statsmodels master. I will go over the details but my first impression is that it looks good. Since it's in the sandbox, we can merge it even if we reorganize later.

    (Two things I saw: numpy docstandard for docstrings, and my guess is plot_hochberg needs a more explicit name to signal it's on multicomparison of means)

    my current AllPairsResult is so far only for p-value correction, it doesn't have information about means, and confidence intervals. So there need to be expansion there to be able to present results like TukeyHSD.

    Also, if you think that MultiComparison is usable, then we can start to move it out of the sandbox.

    I can manage the statistics part and know reasonably well where I would like to be general to expand into other areas of multiple comparisons, but I really appreciate the help with the user interface and additional functions like plots, and the feedback from someone who used similar functions before.

    One additional result: based on some SPSS examples, I looked at "homogenous subset", looking at the cases where the pairwise difference is not rejected and put them in sets. I have a function somewhere but it's not exposed and doesn't have any corresponding plot. (IIRC)

  6. josef-pkt commented on Apr 25, 2013

    @josef-pkt
    MemberAuthor

    Sorry, I just saw now some of your earlier messages. I'm using internet explorer today and it doesn't seem to auto-update.

    The only issues I would raise with this implementation are the way in which the outputs of tukeyhsd() are stored within the MultiComparison instance. They're a little hard to get at unless you know precisely what attribute names you're looking for, or are comfortable with a little introspection.

    Then a Results class that collects all relevant attributes and methods will really be better, and we can have a nice __str__ for printing the full results, besides the plot.

  7. josef-pkt commented on Apr 25, 2013

    @josef-pkt
    MemberAuthor

    Oh, and github is slow in notification, because I'm receiving 2000 scipy tickets that are being moved to github.

  8. jseabold commented on Apr 25, 2013

    @jseabold
    Member
  9. tyleha commented on Apr 25, 2013

    @tyleha
    Contributor

    Ok. So it sounds like:

    1. Leave pairwise_tukey in multicomp to allow different workflows. I suggest changing the docs to reflect the use cases.
    2. Move MultiComparison out of the sandbox and into statsmodels.stats.multicomp. I think it's usable.
    3. Either expand AllPairsResult to be more general for Tukey usage, or create my own Results class for specific Tukey applications. I would be happy to do the latter, but the former should really be done by you as I don't have any clue what else AllPairsResult is being used for. I will start on my own Results class, can merge later.
    4. More explicit name for plot_hochberg

    Happy to help, will make pull request later today or tomorrow.

  10. josef-pkt commented on Apr 25, 2013

    @josef-pkt
    MemberAuthor

    My suggestion for the next step, (forget about any generalized results classes.)

    Start a new class in sandbox.muticomp TukeyHSDResults, instantiate it in the tukey method, and attach all necessary attributes to the result instance, move the current string to a TukeyHSDResults.summary method. Plot might also fit better into the results class.

    (We might need to attach any necessary information about the group instance, or keep a reference to the MultiComparison instance).

    return the results instance in the tukey method of MultiComparison

    This way users have all results nicely together.

    (And I worry about code reuse later, since that will be mainly internal reorganization or introducing inheritance.)

  11. 7 remaining items

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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions