[R] Using Teststatistics (F-Test, T.Test, Wilcox test) and recommended graph

Benjamin Dickgiesser dickgiesser at gmail.com
Tue Nov 7 17:19:26 CET 2006


Hi

it would be nice if someone could tell me if I used the tests
correctly in the following code. I am trying to create a 2-tailed
i) F test for equality of variances
ii) t-test for equality of means
iii) Wilcoxon test for equality of means

data.ceramic <- read.table("ceramic.dat",header=TRUE)
ftest <- var.test(data.ceramic[ data.ceramic$Batch == "1",
]$Y,data.ceramic[ data.ceramic$Batch == "2", ]$Y)
ttest <- t.test(data.ceramic[ data.ceramic$Batch == "1",
]$Y,data.ceramic[ data.ceramic$Batch == "2", ]$Y,var.equal=TRUE)
wtest <- wilcox.test(data.ceramic[ data.ceramic$Batch == "1",
]$Y,data.ceramic[ data.ceramic$Batch == "2", ]$Y)
print(data.frame(Statistic=c(ftest$statistic,ttest$statistic,wtest$statistic),P=c(ftest$p.value,ttest$p.value,wtest$p.value),row.names=c("Equal
Variances", "Equal Means","Nonparametric")))

The data comes in this format:
    Run Lab Batch       Y
1     1   1     1 608.781
2     2   1     2 569.670
3     3   1     1 689.556
4     4   1     2 747.541
5     5   1     1 618.134
6     6   1     2 612.182
7     7   1     1 680.203
8     8   1     2 607.766
9     9   1     1 726.232
10   10   1     2 605.380

and I am comparing the two Batches ignoring any potential differences
between laboratories.

The output my code produces is:

                   Statistic            P
Equal Variances     1.123038 3.703829e-01
Equal Means        13.380581 6.618687e-35
Nonparametric   47635.500000 0.000000e+00


I would also appreciate it very much if someone could recommend me a
type of graph to illustrate the results from the tests. At the moment
I am simply using a boxplot for each batch.
boxplot(Y ~ Batch, data = data.ceramic, horizontal = TRUE,
names=c("Batch1","Batch2"),xlab="Y")

Thank you again!
Benjamin


More information about the R-help mailing list