I have a problem that I think is more of a "logic" problem than a VBA problem, but I need to solve it in VBA in Excel.
I have written a macro that calculates a Kruskal-Wallis nonparametric test. If this test is significant, it runs nonparametric post hoc pairwise comparisons to see which groups are significantly different. This all works without a hitch.
However, I am having trouble outputting the results. I create a matrix of all comparisons, and if the comparison is significant it marks that pair with an asterisk. I wish to modify that so it shows the results like you would get from a statistical package like SAS or SPSS. That is, I want all groups that are not significantly different to have the same letter.
For example, say I'm comparing the height of 4 different corn hybrids. The K-W test says that there is a significant difference between the groups, but I must run the post hoc test to see if groups 1 & 2 are different, 1 & 3 are different, 1 & 4 are different, 2 & 3 are different, 2 & 4 are different, and / or 3 & 4 are different.
Say my results come out like this: 1 is significantly different from all other groups, 2 is different from 1 & 4, 3 is different from 1, and 4 is different from 1 & 2. Thus, my groupings look like this:
1 A
2 B
3 B, C
4 C
See how the letter groupings show significance? And, see how the groups can overlap, so that although 2 is different from 4 and no different from 3, 3 is no different from 4? See how this can make me insane?
So, the question is, how can I come up with a logical method for assigning the letters? Right now, I do it by hand, and I usually get it right by just looking at the groups, but I know that there must be a logical way (because the stat software does it). Doing it by hand gets really tough with more groups and more overlap. Plus, I want a logical way of organizing these comparisons that I can show my students. Any ideas?
Bookmarks