Hi Everyone. I am rather new to R and I've been trying to implement a function to carry out the above test. For a couple of days now I've been stuck on how to generate average rank differences. Say I have a vector of average ranks: averank<- c(2,5,9,12) I would like to subtract averank[1] from averank[2], averank[1] and averank[2] from averank[3] and averank[1], averank[2] and averank[3] from averank[4] etc (I know the syntax is wrong here... it's just for illustration) but I can't work out how to do it. Ideally I would like to generate an array showing the differences between the average ranks so I could tell at a glance which ones were greater than my critical value I've been looking at loops etc but it's a little beyond me at the moment. Thanks for any suggestions. Iain Gallagher IIIR Edinburgh University
Dunn's post hoc test
6 messages · Martin Henry H. Stevens, Iain Gallagher, Robert Baer +1 more
I don't know Dunn's rank test, but the following substracts each of the sums of averanks from the next rank. cumsum(averank)[-length(averank)] - averank[-1] Hank
On Oct 17, 2005, at 4:30 AM, Iain Gallagher wrote:
Hi Everyone. I am rather new to R and I've been trying to implement a function to carry out the above test. For a couple of days now I've been stuck on how to generate average rank differences. Say I have a vector of average ranks: averank<- c(2,5,9,12) I would like to subtract averank[1] from averank[2], averank[1] and averank[2] from averank[3] and averank[1], averank[2] and averank[3] from averank[4] etc (I know the syntax is wrong here... it's just for illustration) but I can't work out how to do it. Ideally I would like to generate an array showing the differences between the average ranks so I could tell at a glance which ones were greater than my critical value I've been looking at loops etc but it's a little beyond me at the moment. Thanks for any suggestions. Iain Gallagher IIIR Edinburgh University
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting- guide.html
Dr. Martin Henry H. Stevens, Assistant Professor 338 Pearson Hall Botany Department Miami University Oxford, OH 45056 Office: (513) 529-4206 Lab: (513) 529-4262 FAX: (513) 529-4243 http://www.cas.muohio.edu/~stevenmh/ http://www.muohio.edu/ecology/ http://www.muohio.edu/botany/ "E Pluribus Unum"
Thanks for your reply Hank. It's not really what I'm after (though it's good to know). For the test ( as described in Statistics for the Biosciences by W. Gardiner. Prentice Hall, 1997) I have to rank my groups, calculate the average rank, then subtratc each average rank from every other. Any value greater than the test statistic is significant. eg average rank difference table: 2 5 8 9 ---|------------------ 2 - 3 6 7 | 5 - - 3 4 | 8 - - - 1 | 9 - - - - | I can't get my head around writing an algorithm for this if I have a vector of average ranks eg averank<- c(2,5,8,9). I know I can address the vector by index and that this is probably the correct route but I can't get the indexing algorithm right! I'm sure someone will point out somethng simple and I'll kick myself but the help would be appreciated. Thanks again. Iain Gallagher --- "Martin Henry H. Stevens" <HStevens at MUOhio.edu> wrote:
I don't know Dunn's rank test, but the following substracts each of the sums of averanks from the next rank. cumsum(averank)[-length(averank)] - averank[-1] Hank On Oct 17, 2005, at 4:30 AM, Iain Gallagher wrote:
Hi Everyone. I am rather new to R and I've been trying to
implement a function to
carry out the above test. For a couple of days now
I've been stuck on
how to generate average rank differences. Say I have a vector of average ranks: averank<- c(2,5,9,12) I would like to subtract averank[1] from
averank[2], averank[1] and
averank[2] from averank[3] and averank[1],
averank[2] and averank[3]
from averank[4] etc (I know the syntax is wrong
here... it's just for
illustration) but I can't work out how to do it. Ideally I would like to generate an array showing
the differences
between the average ranks so I could tell at a
glance which ones were
greater than my critical value I've been looking at loops etc but it's a little
beyond me at the
moment. Thanks for any suggestions. Iain Gallagher IIIR Edinburgh University
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting- guide.html Dr. Martin Henry H. Stevens, Assistant Professor 338 Pearson Hall Botany Department Miami University Oxford, OH 45056 Office: (513) 529-4206 Lab: (513) 529-4262 FAX: (513) 529-4243 http://www.cas.muohio.edu/~stevenmh/ http://www.muohio.edu/ecology/ http://www.muohio.edu/botany/ "E Pluribus Unum"
I think Martin told you the basic approach to the indexing: averank<-sort(sample(1:100,25,replace=TRUE)) averank[-1] - averank[-length(averank)] [1] 1 1 6 3 4 14 1 1 8 1 2 6 5 4 10 0 3 2 1 11 1 1 2 0 averank [1] 4 5 6 12 15 19 33 34 35 43 44 46 52 57 61 71 71 74 76 77 88 89 90 92 92 ----- Original Message ----- From: "IAIN GALLAGHER" <iaingallagher at btopenworld.com> To: "Martin Henry H. Stevens" <HStevens at MUOhio.edu> Cc: <r-help at stat.math.ethz.ch> Sent: Monday, October 17, 2005 2:29 PM Subject: Re: [R] Dunn's post hoc test
Thanks for your reply Hank. It's not really what I'm after (though it's good to know). For the test ( as described in Statistics for the Biosciences by W. Gardiner. Prentice Hall, 1997) I have to rank my groups, calculate the average rank, then subtratc each average rank from every other. Any value greater than the test statistic is significant. eg average rank difference table: 2 5 8 9 ---|------------------ 2 - 3 6 7 | 5 - - 3 4 | 8 - - - 1 | 9 - - - - | I can't get my head around writing an algorithm for this if I have a vector of average ranks eg averank<- c(2,5,8,9). I know I can address the vector by index and that this is probably the correct route but I can't get the indexing algorithm right! I'm sure someone will point out somethng simple and I'll kick myself but the help would be appreciated. Thanks again. Iain Gallagher --- "Martin Henry H. Stevens" <HStevens at MUOhio.edu> wrote:
I don't know Dunn's rank test, but the following substracts each of the sums of averanks from the next rank. cumsum(averank)[-length(averank)] - averank[-1] Hank On Oct 17, 2005, at 4:30 AM, Iain Gallagher wrote:
Hi Everyone. I am rather new to R and I've been trying to
implement a function to
carry out the above test. For a couple of days now
I've been stuck on
how to generate average rank differences. Say I have a vector of average ranks: averank<- c(2,5,9,12) I would like to subtract averank[1] from
averank[2], averank[1] and
averank[2] from averank[3] and averank[1],
averank[2] and averank[3]
from averank[4] etc (I know the syntax is wrong
here... it's just for
illustration) but I can't work out how to do it. Ideally I would like to generate an array showing
the differences
between the average ranks so I could tell at a
glance which ones were
greater than my critical value I've been looking at loops etc but it's a little
beyond me at the
moment. Thanks for any suggestions. Iain Gallagher IIIR Edinburgh University
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting- guide.html Dr. Martin Henry H. Stevens, Assistant Professor 338 Pearson Hall Botany Department Miami University Oxford, OH 45056 Office: (513) 529-4206 Lab: (513) 529-4262 FAX: (513) 529-4243 http://www.cas.muohio.edu/~stevenmh/ http://www.muohio.edu/ecology/ http://www.muohio.edu/botany/ "E Pluribus Unum"
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
I think I misunderstood your follow-up question. Try this:
averank<-sort(sample(1:100,10,replace=TRUE))
x=matrix(nrow=length(averank),ncol=length(averank))
for (i in 1:length(averank)){
+ for (j in 1:length(averank)){
+ x[i,j] <- averank[i] - averank[j]
+ }}
x
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0 -14 -15 -16 -16 -23 -37 -51 -67 -79 [2,] 14 0 -1 -2 -2 -9 -23 -37 -53 -65 [3,] 15 1 0 -1 -1 -8 -22 -36 -52 -64 [4,] 16 2 1 0 0 -7 -21 -35 -51 -63 [5,] 16 2 1 0 0 -7 -21 -35 -51 -63 [6,] 23 9 8 7 7 0 -14 -28 -44 -56 [7,] 37 23 22 21 21 14 0 -14 -30 -42 [8,] 51 37 36 35 35 28 14 0 -16 -28 [9,] 67 53 52 51 51 44 30 16 0 -12 [10,] 79 65 64 63 63 56 42 28 12 0
averank
[1] 15 29 30 31 31 38 52 66 82 94 ----- Original Message ----- From: "IAIN GALLAGHER" <iaingallagher at btopenworld.com> To: "Martin Henry H. Stevens" <HStevens at MUOhio.edu> Cc: <r-help at stat.math.ethz.ch> Sent: Monday, October 17, 2005 2:29 PM Subject: Re: [R] Dunn's post hoc test
Thanks for your reply Hank. It's not really what I'm after (though it's good to know). For the test ( as described in Statistics for the Biosciences by W. Gardiner. Prentice Hall, 1997) I have to rank my groups, calculate the average rank, then subtratc each average rank from every other. Any value greater than the test statistic is significant. eg average rank difference table: 2 5 8 9 ---|------------------ 2 - 3 6 7 | 5 - - 3 4 | 8 - - - 1 | 9 - - - - | I can't get my head around writing an algorithm for this if I have a vector of average ranks eg averank<- c(2,5,8,9). I know I can address the vector by index and that this is probably the correct route but I can't get the indexing algorithm right! I'm sure someone will point out somethng simple and I'll kick myself but the help would be appreciated. Thanks again. Iain Gallagher --- "Martin Henry H. Stevens" <HStevens at MUOhio.edu> wrote:
I don't know Dunn's rank test, but the following substracts each of the sums of averanks from the next rank. cumsum(averank)[-length(averank)] - averank[-1] Hank On Oct 17, 2005, at 4:30 AM, Iain Gallagher wrote:
Hi Everyone. I am rather new to R and I've been trying to
implement a function to
carry out the above test. For a couple of days now
I've been stuck on
how to generate average rank differences. Say I have a vector of average ranks: averank<- c(2,5,9,12) I would like to subtract averank[1] from
averank[2], averank[1] and
averank[2] from averank[3] and averank[1],
averank[2] and averank[3]
from averank[4] etc (I know the syntax is wrong
here... it's just for
illustration) but I can't work out how to do it. Ideally I would like to generate an array showing
the differences
between the average ranks so I could tell at a
glance which ones were
greater than my critical value I've been looking at loops etc but it's a little
beyond me at the
moment. Thanks for any suggestions. Iain Gallagher IIIR Edinburgh University
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting- guide.html Dr. Martin Henry H. Stevens, Assistant Professor 338 Pearson Hall Botany Department Miami University Oxford, OH 45056 Office: (513) 529-4206 Lab: (513) 529-4262 FAX: (513) 529-4243 http://www.cas.muohio.edu/~stevenmh/ http://www.muohio.edu/ecology/ http://www.muohio.edu/botany/ "E Pluribus Unum"
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
Or more simply: averank<-sort(sample(1:100,10,replace=TRUE)) outer(averank, averank, "-") Hadley
On 10/17/05, Robert Baer <rbaer at atsu.edu> wrote:
I think I misunderstood your follow-up question. Try this:
averank<-sort(sample(1:100,10,replace=TRUE))
x=matrix(nrow=length(averank),ncol=length(averank))
for (i in 1:length(averank)){
+ for (j in 1:length(averank)){
+ x[i,j] <- averank[i] - averank[j]
+ }}
x
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0 -14 -15 -16 -16 -23 -37 -51 -67 -79 [2,] 14 0 -1 -2 -2 -9 -23 -37 -53 -65 [3,] 15 1 0 -1 -1 -8 -22 -36 -52 -64 [4,] 16 2 1 0 0 -7 -21 -35 -51 -63 [5,] 16 2 1 0 0 -7 -21 -35 -51 -63 [6,] 23 9 8 7 7 0 -14 -28 -44 -56 [7,] 37 23 22 21 21 14 0 -14 -30 -42 [8,] 51 37 36 35 35 28 14 0 -16 -28 [9,] 67 53 52 51 51 44 30 16 0 -12 [10,] 79 65 64 63 63 56 42 28 12 0
averank
[1] 15 29 30 31 31 38 52 66 82 94 ----- Original Message ----- From: "IAIN GALLAGHER" <iaingallagher at btopenworld.com> To: "Martin Henry H. Stevens" <HStevens at MUOhio.edu> Cc: <r-help at stat.math.ethz.ch> Sent: Monday, October 17, 2005 2:29 PM Subject: Re: [R] Dunn's post hoc test
Thanks for your reply Hank. It's not really what I'm after (though it's good to know). For the test ( as described in Statistics for the Biosciences by W. Gardiner. Prentice Hall, 1997) I have to rank my groups, calculate the average rank, then subtratc each average rank from every other. Any value greater than the test statistic is significant. eg average rank difference table: 2 5 8 9 ---|------------------ 2 - 3 6 7 | 5 - - 3 4 | 8 - - - 1 | 9 - - - - | I can't get my head around writing an algorithm for this if I have a vector of average ranks eg averank<- c(2,5,8,9). I know I can address the vector by index and that this is probably the correct route but I can't get the indexing algorithm right! I'm sure someone will point out somethng simple and I'll kick myself but the help would be appreciated. Thanks again. Iain Gallagher --- "Martin Henry H. Stevens" <HStevens at MUOhio.edu> wrote:
I don't know Dunn's rank test, but the following substracts each of the sums of averanks from the next rank. cumsum(averank)[-length(averank)] - averank[-1] Hank On Oct 17, 2005, at 4:30 AM, Iain Gallagher wrote:
Hi Everyone. I am rather new to R and I've been trying to
implement a function to
carry out the above test. For a couple of days now
I've been stuck on
how to generate average rank differences. Say I have a vector of average ranks: averank<- c(2,5,9,12) I would like to subtract averank[1] from
averank[2], averank[1] and
averank[2] from averank[3] and averank[1],
averank[2] and averank[3]
from averank[4] etc (I know the syntax is wrong
here... it's just for
illustration) but I can't work out how to do it. Ideally I would like to generate an array showing
the differences
between the average ranks so I could tell at a
glance which ones were
greater than my critical value I've been looking at loops etc but it's a little
beyond me at the
moment. Thanks for any suggestions. Iain Gallagher IIIR Edinburgh University
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting- guide.html Dr. Martin Henry H. Stevens, Assistant Professor 338 Pearson Hall Botany Department Miami University Oxford, OH 45056 Office: (513) 529-4206 Lab: (513) 529-4262 FAX: (513) 529-4243 http://www.cas.muohio.edu/~stevenmh/ http://www.muohio.edu/ecology/ http://www.muohio.edu/botany/ "E Pluribus Unum"
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html