Tuesday, April 14, 2009

Parametric and non-parametric t-testing

If your data are distributed normally, the t-test can help you determine if the means of your two samples are greater than or less than each other (one-tailed) or just plain different from each other (two-tailed). These examples are for paired samples, to make them not paired just delete the "paired=TRUE" statement altogether, default is unpaired.

We'll use the same data throughout:
x <- c(1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30)
y <- c(0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29)

When using your own data you just need them in vectors (as shown).



What if your data are not normal? The non-parametric Wilcoxon test will do the trick. The Wilcoxon rank-sum test is for independent samples (unpaired). The Wilcoxon signed rank test is for paired samples.

wilcox.test(x, y, paired = TRUE)

No comments: