1.6.9.1.4: Testing...
( \newcommand{\kernel}{\mathrm{null}\,}\)
The significance of difference between means for paired parametric data (t-test for paired data):
Code 1.6.9.1.4.1 (R):
... t-test for independent data:
Code 1.6.9.1.4.2 (R):
(Last example is for learning purpose only because our data is paired since every row corresponds with one animal. Also, "paired=FALSE" is the default for the t.test(), therefore one can skip it.)
Here is how to compare values of one character between two groups using formula interface:
Code 1.6.9.1.4.3 (R):
Formula was used because our weight/sex data is in the long form:
Code 1.6.9.1.4.4 (R):
Convert weight/sex data into the short form and test:
Code 1.6.9.1.4.5 (R):
(Note that test results are exactly the same. Only format was different.)
If the p-value is equal or less than 0.05, then the difference is statistically supported. R does not require you to check if the dispersion is the same.
Nonparametric Wilcoxon test for the differences:
Code 1.6.9.1.4.6 (R):
One-way test for the differences between three and more groups (the simple variant of ANOVA, analysis of variation):
Code 1.6.9.1.4.7 (R):
Which pair(s) are significantly different?
Code 1.6.9.1.4.8 (R):
(We used Bonferroni correction for multiple comparisons.)
Nonparametric Kruskal-Wallis test for differences between three and more groups:
Code 1.6.9.1.4.9 (R):
Which pairs are significantly different in this nonparametric test?
Code 1.6.9.1.4.10 (R):
The significance of the correspondence between categorical data (nonparametric Pearson chi-squared, or χ2 test):
Code 1.6.9.1.4.11 (R):
The significance of proportions (nonparametric):
Code 1.6.9.1.4.12 (R):
(Here we checked if this is true that the proportion of male is different from 50%.)
The significance of linear correlation between variables, parametric way (Pearson correlation test):
Code 1.6.9.1.4.13 (R):
... and nonparametric way (Spearman’s correlation test):
Code 1.6.9.1.4.14 (R):
The significance (and many more) of the linear model describing relation of one variable on another:
Code 1.6.9.1.4.15 (R):
... and analysis of variation (ANOVA) based on the linear model:
Code 1.6.9.1.4.16 (R):