In general, you wouldn't necessarily expect one way ANOVA and the Kruskal-Wallis to be similar, sometimes they can give quite different p-values. See here for a little partial motivation for why you might expect a difference. [When samples are reasonably normal-looking and with means not too many standard errors apart, they often tend to give similar p-values. Outside that, they frequently don't.]
However, in this case the reason is more prosaic: Your Kruskal-Wallis p-value is wrong.
Here's a summary of results in R (details below).
p-value
Welch t-test: 0.001287
Equal-var. t-test: 8.552e-05
One way anova: 8.55e-05
Wilcoxon test: 0.004847
Kruskal-Wallis: 0.003761
(Neither of the last two p-values are exact; if they were, you'd get the same p-value for the two-group comparison.)
Your problem is you're treating the second group's data as a factor (see the end of this answer).
Here's what I get in R with your data:
frh <- data.frame(group1 = c(103.56, 103.32, 103.32, 104.27, 103.56, 103.8),
group2 = c( 97.16, 97.16, 96.69, 98.58, 90.76, 97.64))
# strip chart:
# Welch t-test:
> with(frh,t.test(group1,group2))
Welch Two Sample t-test
data: group1 and group2
t = 6.3316, df = 5.163, p-value = 0.001287
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
4.368147 10.245186
sample estimates:
mean of x mean of y
103.63833 96.33167
$\,$
# equal-variance t-test:
> with(frh,t.test(group1,group2,var.equal=TRUE))
Two Sample t-test
data: group1 and group2
t = 6.3316, df = 10, p-value = 8.552e-05
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
4.735411 9.877922
sample estimates:
mean of x mean of y
103.63833 96.33167
$\,$
#one way anova:
summary(aov(values~ind,stack(frh)))
Df Sum Sq Mean Sq F value Pr(>F)
ind 1 160.16 160.2 40.09 8.55e-05 ***
Residuals 10 39.95 4.0
$\,$
# Wilcoxon-Mann-Whitney:
> with(frh,wilcox.test(group1,group2))
Wilcoxon rank sum test with continuity correction
data: group1 and group2
W = 36, p-value = 0.004847
alternative hypothesis: true location shift is not equal to 0
Warning message:
In wilcox.test.default(group1, group2) :
cannot compute exact p-value with ties
$\,$
# Kruskal-Wallis test:
> kruskal.test(frh)
Kruskal-Wallis rank sum test
data: frh
Kruskal-Wallis chi-squared = 8.3958, df = 1, p-value = 0.003761
Those are all about as consistent with each other as I would expect on that data.
Now, here's how to get what you got for the Kruskal-Wallis:
with(frh,kruskal.test(group1,group2))
Kruskal-Wallis rank sum test
data: group1 and group2
Kruskal-Wallis chi-squared = 4.3939, df = 4, p-value = 0.3553
The problem is, if you're getting this, you're using it wrong. That's not how the function works - group2
is being treated as a factor defining different groups for data in group1
.
So the main reason the Kruskal Wallis isn't giving you a roughly similar p-value to ANOVA is you didn't call it correctly.
You will want to read the question What is the difference between various Kruskal-Wallis post-hoc tests? and my answer to it.
From that answer:
dunn.test
provides Dunn's (1964) z test approximation to a rank sum test employing both the same ranks used in the Kruskal-Wallis test, and the pooled variance estimate implied by the null hypothesis of the Kruskal-Wallis (akin to using the pooled variance to calculate t test statistics following an ANOVA).
The kruskalmc
function in the pgirmess
package implements Dunn's post hoc rank sum comparison using z test statistics as directed by Siegel and Castellan (1988), but these authors do not include Dunn's (1964) correction for ties, so kruskalmc
will be less accurate than dunn.test
when ties exist in the data.
For your second question, you will want to read the question Can a CDF from data cross with another CDF? and its answer.
References
Dunn, O. J. (1964). Multiple comparisons using rank sums. Technometrics, 6(3):241–252.
Siegel and Castellan (1988) Non parametric statistics for the behavioural sciences. MacGraw Hill Int., New York. pp 213-214
Best Answer
With
dunn.test
you have an argumentaltp
which sets how the p-value will be expressed. If in function call you setaltp=TRUE
, then the p values will be expressed in alternative format.Test default is to express p-value = P(Z ≥ |z|), and reject Ho if p ≤ α/2. So what you describe sounds like normal behaviour. You still can change it - if the
altp
option is used, p-values are instead expressed as p-value = P(|Z| ≥ |z|), and Ho is rejected if p ≤ α.As it´s said in documentation, both expressions should anyway give identical test results so the use of altp is therefore merely a semantic choice".