Discussion:
[R] Letter-based representation of pairwise comparisons
retama
2009-01-08 11:40:04 UTC
Permalink
Hi!

I have been working several years with R but it's my first public question.
I hope I'll be clear :) .

This question is related to obtaining letter-based representation of
non-parametric pairwise comparisons.

I have a dataframe with this structure (but with quite more rows and cols):

A B C factor
1 2 2 one
2 1 2 one
2 2 3 two
2 3 2 two
1 4 2 three
9 8 1 three

I have no normality, so I did a kruskal test which showed significant
differences in some cases. As post hoc pairwise comparisons (the idea is to
make an equivalent to Tukey test after an ANOVA) I tried with a paired
wilcoxon test with the Bonferroni's correction (pairwise.wilcox.test(A,
factor, p.adj="bonf") and other for B, and so on) and, now, I need to modify
the output to show a letter-based representation of all pairwise
comparisons. Some algorithms have been published
(http://www.accessmylibrary.com/coms2/summary_0286-21655824_ITM), but I
can't find an R implementation.

Does anyone know how to do that?

Thank you!!

Retama
--
View this message in context: http://www.nabble.com/Letter-based-representation-of-pairwise-comparisons-tp21350364p21350364.html
Sent from the R help mailing list archive at Nabble.com.
hadley wickham
2009-01-08 17:35:16 UTC
Permalink
Post by retama
Hi!
I have been working several years with R but it's my first public question.
I hope I'll be clear :) .
This question is related to obtaining letter-based representation of
non-parametric pairwise comparisons.
A B C factor
1 2 2 one
2 1 2 one
2 2 3 two
2 3 2 two
1 4 2 three
9 8 1 three
I have no normality, so I did a kruskal test which showed significant
differences in some cases. As post hoc pairwise comparisons (the idea is to
make an equivalent to Tukey test after an ANOVA) I tried with a paired
wilcoxon test with the Bonferroni's correction (pairwise.wilcox.test(A,
factor, p.adj="bonf") and other for B, and so on) and, now, I need to modify
the output to show a letter-based representation of all pairwise
comparisons. Some algorithms have been published
(http://www.accessmylibrary.com/coms2/summary_0286-21655824_ITM), but I
can't find an R implementation.
http://cran.r-project.org/web/packages/multcompView/ ?

Hadley
--
http://had.co.nz/
I M G
2009-01-09 10:07:11 UTC
Permalink
An embedded and charset-unspecified text was scrubbed...
Name: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090109/05d033ca/attachment-0001.pl>
retama
2009-02-02 10:20:01 UTC
Permalink
I solved it. It was quite easy:

Because each test is a list, it's necessary to specify which element
show(test)
An object of class ?pairwise.htest?
$method
[1] "Wilcoxon rank sum test"

$data.name
[1] "SAND and Organ"

$p.value
FlowerA FlowerB FlowerC FlowerD LeafA
FlowerB 0.000617030 NA NA NA NA
FlowerC 0.000617030 0.004319210 NA NA NA
FlowerD 0.000617030 0.000617030 0.000617030 NA NA
LeafA 0.006141902 0.006141902 0.006141902 0.006141902 NA
LeafC 0.000617030 0.000617030 0.000617030 0.000617030 0.3242459

$p.adjust.method
[1] "bonferroni"
multcompLetters(test$p.value)
FlowerB FlowerC FlowerD LeafA LeafC
"a" "b" "c" "d" "e"

Thank you!

Retama
--
View this message in context: http://www.nabble.com/Letter-based-representation-of-pairwise-comparisons-tp21350364p21787201.html
Sent from the R help mailing list archive at Nabble.com.
goz
2009-10-06 11:57:09 UTC
Permalink
hello,

i try to use the multcomp letters, but i have problems with my results :

here is my pvalue matrix (from a pairwise.t.test) :

pair=pairwise.t.test(...)
pair$p.value

0 B BxS
B 0.01727 - -
BxS 0.00013 0.00226 -
S 0.87555 0.02610 0.00027


i was thiking to have something like that :
0 B S BxS
a b a c
multcompLetters(pair$p.value)
B BxS S
"a" "b" "a"


first question : why the 0 traitement doesn't appears in result ?
second : why the results differs than what i expected ?

many thanks.
--
View this message in context: http://www.nabble.com/Letter-based-representation-of-pairwise-comparisons-tp21350364p25767357.html
Sent from the R help mailing list archive at Nabble.com.
goz
2009-10-06 15:10:21 UTC
Permalink
Ok, thanks for all your responses,

i was thinking, after reading the firsts messages that use only the $p.value
was good. By using a symetric matrix results are ok.
It's also good with a pvalue vector (just like exemples in the help ...).

many thanks for your help
--
View this message in context: http://www.nabble.com/Letter-based-representation-of-pairwise-comparisons-tp21350364p25770624.html
Sent from the R help mailing list archive at Nabble.com.
retama
2009-10-06 14:33:11 UTC
Permalink
Hello:

That's because the required input should be a symmetric matrix with all the
comparisons, e.g., it should have the self-comparisons diagonal. In an
hypotetical case with two treatments, the pairwise-comparison test output is
something like that:

A B
B 0.80 -

but multcompView requires an input like that one:

A B
A 1 -
B 0.80 1

That means you should add a new row and column for your missing treatments
and, then, a diagonal of "1"s meaning that each treatment compared with
itself will result in a p-value of 1 (maximal identity). Then, the new
matrix could be piped succesfully.

Regards,

Retama
Post by goz
hello,
pair=pairwise.t.test(...)
pair$p.value
0 B BxS
B 0.01727 - -
BxS 0.00013 0.00226 -
S 0.87555 0.02610 0.00027
0 B S BxS
a b a c
multcompLetters(pair$p.value)
B BxS S
"a" "b" "a"
first question : why the 0 traitement doesn't appears in result ?
second : why the results differs than what i expected ?
many thanks.
--
View this message in context: http://www.nabble.com/Letter-based-representation-of-pairwise-comparisons-tp21350364p25769894.html
Sent from the R help mailing list archive at Nabble.com.
Loading...