8.4: Testing...
- Page ID
- 3599
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \newcommand{\dsum}{\displaystyle\sum\limits} \)
\( \newcommand{\dint}{\displaystyle\int\limits} \)
\( \newcommand{\dlim}{\displaystyle\lim\limits} \)
\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)
( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\id}{\mathrm{id}}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\kernel}{\mathrm{null}\,}\)
\( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\)
\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\)
\( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\(\newcommand{\longvect}{\overrightarrow}\)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\ket}[1]{\left| #1 \right>}\)
\(\newcommand{\bra}[1]{\left< #1 \right|}\)
\(\newcommand{\braket}[2]{\left< #1 \vphantom{#2} \right| \left. #2 \vphantom{#1} \right>}\)
\(\newcommand{\braopket}[3]{\left< #1 \vphantom{#2}\vphantom{#3} \right| #2 \vphantom{#1}\vphantom{#3} \left| #3 \vphantom{#1}\vphantom{#2} \right>}\)
\(\newcommand{\qmvec}[1]{\mathbf{\vec{#1}}}\)
\(\newcommand{\op}[1]{\hat{\mathbf{#1}}}\)
\(\newcommand{\expect}[1]{\langle #1 \rangle}\)
\(\newcommand{\dfn}[1]{\emph{\textbf{#1}}}\)
The significance of difference between means for paired parametric data (t-test for paired data):
Code \(\PageIndex{1}\) (R):
... t-test for independent data:
Code \(\PageIndex{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 \(\PageIndex{3}\) (R):
Formula was used because our weight/sex data is in the long form:
Code \(\PageIndex{4}\) (R):
Convert weight/sex data into the short form and test:
Code \(\PageIndex{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 \(\PageIndex{6}\) (R):
One-way test for the differences between three and more groups (the simple variant of ANOVA, analysis of variation):
Code \(\PageIndex{7}\) (R):
Which pair(s) are significantly different?
Code \(\PageIndex{8}\) (R):
(We used Bonferroni correction for multiple comparisons.)
Nonparametric Kruskal-Wallis test for differences between three and more groups:
Code \(\PageIndex{9}\) (R):
Which pairs are significantly different in this nonparametric test?
Code \(\PageIndex{10}\) (R):
The significance of the correspondence between categorical data (nonparametric Pearson chi-squared, or \(\chi^2\) test):
Code \(\PageIndex{11}\) (R):
The significance of proportions (nonparametric):
Code \(\PageIndex{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 \(\PageIndex{13}\) (R):
... and nonparametric way (Spearman’s correlation test):
Code \(\PageIndex{14}\) (R):
The significance (and many more) of the linear model describing relation of one variable on another:
Code \(\PageIndex{15}\) (R):
... and analysis of variation (ANOVA) based on the linear model:
Code \(\PageIndex{16}\) (R):


