Two-sample analysis

It’s now time for things to get serious: we have more than one sample! Actually two! But what do we want to do with these two samples? Compare their variances? Their means? And what about correlating two variables? Here is a series of useful tests and functions in R to take care of these two groups of data.




Comparing means is not the only way to compare two samples. Here is an example where proportions or rates may be used to compare groups. Here is a quick example: You run an experiment where mice dispatched in 2 groups (a control and an experimental group) are tested for their capacity […]

3. Comparing two proportions



Often when handling big dataset and when (desperately) searching for some sense in this big pile of numbers, you will find yourself searching for connections, for variables which seem to change at the same time, in the same or opposite direction… Most of the time you will be looking at big […]

4. Comparing two variables


Student’s t-test (also known as Welch two sample test) requires that samples are independent, of equal variance and normally distributed. The Shapiro-Wilk test may thus be employed to check for normality prior to performing the comparison; Fisher’s F test will help checking for equal variances. In Student’s t-test, the null hypothesis […]

Comparing two means – Student’s t-test




The Kruskal-Wallis test (also known as One-way ANOVA on ranks) can be used for comparison of two or more independent samples. It is a non-parametric test which does not require normality of distribution, and which can thus replace Student’s t-test or the One-way ANOVA. The function in R is kruskal.test(x, y) where x […]

Comparing two means – Kruskal-Wallis test