+ Reply to Thread
Results 1 to 19 of 19

Complex correlations

  1. #1
    Registered User
    Join Date
    08-04-2010
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2007
    Posts
    10

    Complex correlations

    Hi all
    I've been trying to find a way to compare and code correlations,
    the following is a list of mean values:
    Day Mean
    1 58
    2 12
    3 35
    4 14
    5 42
    6 9
    7 12
    LSD= 17
    Any difference between means smaller than the 'least significant difference' (LSD) is not significant, anything equal to or over LSD is significant.
    I need to attribute means to groups; the means within a group are not significantly different from each other but are significantly different from the means in other groups.
    Groups would be letters a - g
    Values can be in more than one group
    The group with the smallest mean must be group 'a', the next mean value significantly different from any member of group 'a' must begin group 'b' and so on.
    The above example should read:
    Day Mean Group
    1 58 c
    2 12 a
    3 35 b
    4 14 a
    5 42 b,c
    6 9 a
    7 12 a

    Hopefully you can help before I pull all my hair out!
    Last edited by Razyg; 08-04-2010 at 09:44 AM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Complex correlations

    Why is 42 in b and c? I don't think I follow this...

  3. #3
    Registered User
    Join Date
    08-04-2010
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Complex correlations

    I know it's frustratingly complicated sorry; that's why I want to automate it as I keep making mistakes manually:
    the difference between 42 and 58 is less than 17 so they have to be in the same group,
    The difference between 42 and 35 is less than 17 so they have to be in the same group,
    but,
    The difference between 35 and 58 is more than 17 so they have to be in different groups,
    Therefore 35 and 58 are in different groups but 42 is has to be in both groups.

    Thanks to anyone spending time on this mind bender!

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Complex correlations

    OK, I see. How many data items are you likely to have - is seven just illustrative?

  5. #5
    Registered User
    Join Date
    08-04-2010
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Complex correlations

    seven is the max it's usually 'only' five.

  6. #6
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Complex correlations

    This works for your example, but better test it thoroughly.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-04-2010
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Complex correlations

    Thats wonderful thank you! I'm going to test it out here with a few different sets.
    I'm very grateful you know =)

  8. #8
    Registered User
    Join Date
    08-04-2010
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Complex correlations

    I can't get this code to work in all situations sorry; when all means are different from each other for example. I tried working with your code but my programming isn't good enough- the only way I can get this to work is by using long nested formulas and since they're so nested they'll only work in excel 2007 which means I can't work on them at home.... is it possible to write VBA along these lines?
    For these formulas it's essential that a 'sort by column b' runs first so that all means are in ascending order, a 'sort by column a' after to put everything back in the right order is handy too but whether this is essential in VBA I'm not sure!

    I attached an xlsx for anyone with 2007 and a doc to show the formulas for anyone without.

    Kind regards all


    There is a problem with these formulas please ignore their system
    Attached Files Attached Files
    Last edited by Razyg; 08-12-2010 at 04:41 AM. Reason: incorrect solution

  9. #9
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Complex correlations

    I will take a look, but could you provide an example of it not working? I probably haven't understood fully all the concepts involved.

    EDIT: in the meantime, see if this addresses any problems. You'll see that it puts some formulae in K and L, but these could be moved or removed. First, see if it rectifies problems.
    Please Login or Register  to view this content.
    Last edited by StephenR; 08-10-2010 at 12:49 PM.

  10. #10
    Registered User
    Join Date
    08-04-2010
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Complex correlations

    Thanks Stephen,

    This is getting really close it's great!
    I've attached a sheet with a few examples of working and not working groups, your latest code from yesterday is in module 1, I just changed nLSD to relate to cell D2 as it's value differs depending on the variability between means.

    I always wondered why the stats package that generates these means and LSD values doesn't also group means automatically; I think I understand why now!

    Hope this isn't driving you too crazy!

    Thanks gain.
    Attached Files Attached Files

  11. #11
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Complex correlations

    No, it's quite a teaser. I have reached a mental block when it comes to the ranking bit. When I get through that will post back!

    EDIT: actually, no it is driving me a bit crazy. I have sorted out the ranking issue which addresses the first two cases in your file. However, the other two suggest that there is a fundamental problem with my method which needs re-examination. I hope you're not in a hurry.
    Last edited by StephenR; 08-11-2010 at 12:14 PM.

  12. #12
    Registered User
    Join Date
    08-04-2010
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Complex correlations

    The fourth 'not working' example was bugging me after I'd posted it, your code got it right and I got it wrong manually: in my example, mean number 4 is in the same group as number 2 but it shouldn't be, your code is definitely right I checked and checked last night sorry!
    Also, when I ran the second last example again I got a different result to the one in the spreadsheet- the pattern was spot on just muddled ranking like the other 2 examples-
    I think you may have solved this for me and I went and confused you with wrong examples!

    I do feel rather sheepish! sorry

  13. #13
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Complex correlations

    Ho hum, you had actually convinced me that my method was not correct. I'll keep schtum from now on... See if this code is an improvement - it makes sure the groups proceed a,b,c etc rather than a,d,g.
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    08-04-2010
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Complex correlations

    You're very kind not to scold me!

    Lots of complicated one's are working perfectly now, although there are a few more strange ones (attached again). the last macro worked better on these for some reason, I'm affraid I can't work out what the code's actually doing now so I couldn't pick out what the change may be doing.... I hope you can!

    kind regards,

    Graham
    Attached Files Attached Files

  15. #15
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Complex correlations

    Graham - I have a little wax effigy I stick pins into so that I can vent my spleen while appearing placid on the forum. Below is a slightly different (and simpler) approach which seems to work in some of the cases where it previously didn't. However, I was not entirely clear from your example where all the problems were, so please feel free to elaborate on that. I hope we're making progress.
    Please Login or Register  to view this content.
    Last edited by StephenR; 08-12-2010 at 03:08 PM.

  16. #16
    Registered User
    Join Date
    08-04-2010
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Complex correlations

    Thanks Stephen- progress is wonderful thank you, I'm very impressed and certainly grateful of all your time.
    This latest code actually seems to just rank means a-g from smallest to largest, it doesn't look like it's using LSD correctly and so it's struggling with all the past examples that had previously worked.

    What I was trying to do in those few examples that weren't working was change cetain aspects and see where the macro stumbled; it looks like the macro is more accurate when there are fewer decimal places involved.
    I did wonder if examples with small differences, differences that were only just inside LSD, were throwing it off but the very last example in book 2 worked fine so I don't think that's the case.

    Please don't feel limited by these examples; they are just made up numbers to fit an expected group order which I then run to see if what I expected comes back, if it helps to make up your own figures to incorperate into the model please do.

    This has become a long week ofor you sorry- I may need to send you a new wax figure to replace the worn out one! and no hurry don't panic!

    regards,
    Graham

  17. #17
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Complex correlations

    Graham - oh dear, back to the drawing board. I thought it was producing the right results, but maybe was unclear. What would be helpful if you could make absolutely clear what the results should be for those examples and then I can be sure I am working to the right end.

  18. #18
    Registered User
    Join Date
    08-04-2010
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Complex correlations

    I've tried not to confuse things with 'what the macro got/ what it should have got' and just included examples as they should turn out, hopefully this helps.
    I think it's almost there as a set can work perfectly, then if I add more units after the decimal on either the means or the LSD confusion arises.
    So far I get the best results with the second edit of code if that helps?

    you'll be seeing little a's and b's in your sleep all weekend!
    Attached Files Attached Files

  19. #19
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Complex correlations

    Quite likely. I get most of my best ideas at 4am.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1