Reputation: 21
data(ChickWeight)
head(ChickWeight)
plot( ChickWeight$Time, ChickWeight$weight, col=ChickWeight$Diet)
chick = reshape(ChickWeight, idvar=c("Chick","Diet"), timevar="Time",
direction="wide")
head(chick)
chick = na.omit(chick)
Perform a t-test of x and y, after adding a single chick of weight 200 grams to x (the diet 1 chicks). What is the p-value from this test? The p-value of a test is available with the following code: t.test(x,y)$p.value
Do the same for the Wilcoxon test. The Wilcoxon test is robust to the outlier. In addition, it has less assumptions that the t-test on the distribution of the underlying data.
When I try do Wilcoxon test:
wilcox.test(c(x, 200), y)
I get this error:
Warning message:
In wilcox.test.default(c(x, 200), y) :
cannot compute exact p-value with ties
Upvotes: 1
Views: 119
Reputation: 79194
Use exactRankTests::wilcox.exact
:
If x
is a weight for example time 0 e.g. chick$weight.0
and
y
is a weight for example time 2 e.g. chick$weight.2
Then you could do it this way:
With wilcox.test
you will get a warning message:
> wilcox.test(c(chick$weight.0, 200), chick$weight.2)$p.value
[1] 6.660003e-14
Warning message:
In wilcox.test.default(c(chick$weight.0, 200), chick$weight.2) :
cannot compute exact p-value with ties
Use exactRankTests::wilcox.exact()
that can handle ties:
t.test(chick$weight.0,chick$weight.2)$p.value
6.660003e-14
exactRankTests::wilcox.exact(c(chick$weight.0, 200), chick$weight.2)$p.value
[1] 5.889809e-18
Upvotes: 1