I am a noob in R, and have been breaking my head for the past three hours over the pairwise.t.test in R. My data frame is structured as given below. My data frame has the age of flight of bees and the duration which they fly for. I want to check the pairwise difference in duration across days.
head(a3)
age dur.
1 3 343
2 2 640
3 1 333
4 3 253
5 3 66
6 3 686
When I do one-way ANOVA and follow it up with a TukeyHSD, the console prints the values for adjusted p-values.
> an3=with(a3, aov(dur.~factor(age)))
> TukeyHSD(an3)
Tukey multiple comparisons of means
95% family-wise confidence level
Fit: aov(formula = dur. ~ factor(age))
$`factor(age)`
diff lwr upr p adj
2-1 -16.666667 -1215.7557943 1182.42246 1.0000000
3-1 -105.717444 -1158.4831001 947.04821 1.0000000
4-1 -144.603500 -1198.2056799 908.99868 1.0000000
5-1 -194.405800 -1244.3222876 855.51069 1.0000000
6-1 -223.139535 -1273.5866854 827.30762 1.0000000
7-1 -143.568966 -1190.9244371 903.78651 1.0000000
8-1 -208.927536 -1254.8670531 837.01198 1.0000000
9-1 -255.583333 -1304.7863200 793.61965 0.9999999
I want to carry out pairwise.t.test with the Bonferroni p-value adjustment on the data frame. When I go ahead and do that, I get the following output.
pairwise.t.test(a3
$dur.,a3
$age,p.adjust.method='bonf')
Pairwise comparisons using t tests with pooled SD
data: a3$dur. and a3$age
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
2 - - - - - - - - - - - - - - - - - - - - - - - -
3 - - - - - - - - - - - - - - - - - - - - - - - -
4 - - - - - - - - - - - - - - - - - - - - - - - -
5 - - - - - - - - - - - - - - - - - - - - - - - -
6 - - - - - - - - - - - - - - - - - - - - - - - -
7 - - - - - - - - - - - - - - - - - - - - - - - -
8 - - - - - - - - - - - - - - - - - - - - - - - -
...
P value adjustment method: bonferroni
I do not know why I get blanks for all fields, when in all examples I have seen online, the result is a lower triangular matrix. Has anyone faced similar problems? Are there any solutions for the same?
Cheers
P.S. I have tried the example given in R documentation and it seems to work fine. It's not working for my data set though. I have also ensured that the example data and my data are both data frames.
Best Answer
I ran into the same problem just now, but realized the common issue was that some of your groups only included one value. For example, the following results in the same - - table as you saw before.
However, when you no longer have categories with only one value, the pairwise.t.test works. (In this case, I changed "b" to "a" so that there are now two values in "a" and two in "b".)