Sokal and Rohlf (1997) presented a dataset comprising the lengths of cheliceral bases (in um) from two samples of chigger (Trombicula lipovskyi) nymphs. These data were used to illustrate two equivalent tests (Mann-Whitney U-test and Wilcoxon two-sample test) of location equality (Box 13.7 of Sokal and Rohlf (1997)).

Reset R’s memory

rm(list=ls())

Step 1

Import the nymph data set using these codes.

setwd("C://Users/April Mae Tabonda//Documents//MS Marine Science//Biostat//PLP//RMDs//PLP_7 T-Test")
getwd()
## [1] "C:/Users/April Mae Tabonda/Documents/MS Marine Science/Biostat/PLP/RMDs/PLP_7 T-Test"
nymphs <-read.csv("nymphs.csv", header=TRUE, sep=',')
head(nymphs)
##     SAMPLE LENGTH
## 1 Sample A    104
## 2 Sample A    109
## 3 Sample A    112
## 4 Sample A    114
## 5 Sample A    116
## 6 Sample A    118
tail(nymphs)
##      SAMPLE LENGTH
## 21 Sample B    108
## 22 Sample B    111
## 23 Sample B    116
## 24 Sample B    120
## 25 Sample B    121
## 26 Sample B    123
str(nymphs)
## 'data.frame':    26 obs. of  2 variables:
##  $ SAMPLE: Factor w/ 2 levels "Sample A","Sample B": 1 1 1 1 1 1 1 1 1 1 ...
##  $ LENGTH: int  104 109 112 114 116 118 118 119 121 123 ...

Step 2

We assessed assumptions of normality and homogeneity of variance for the null hypothesis.

boxplot(LENGTH~SAMPLE, data=nymphs)

In your PLP, use ggplot to produce both boxplot and quantile-quantile plot to check for normality, see scripts from Example 1. Label the plots.

with(nymphs,rbind(MEAN=tapply(LENGTH,SAMPLE,mean),
                  VAR=tapply(LENGTH,SAMPLE,var),
                  SD=tapply(LENGTH,SAMPLE,sd)))
##       Sample A   Sample B
## MEAN 119.68750 111.800000
## VAR   53.29583  60.177778
## SD     7.30040   7.757434
pacman::p_load(car)
leveneTest(nymphs$LENGTH, nymphs$SAMPLE)
## Levene's Test for Homogeneity of Variance (center = median)
##       Df F value Pr(>F)
## group  1  0.0749 0.7867
##       24

Conclusions

While there is no evidence of unequal variance, there is some (possible) evidence of non-normality (boxplots slightly asymmetrical). These data will therefore be analysed using a non-parametric. Mann-Whitney-Wilcoxon signed rank test.

Step 3

Perform a Mann-Whitney Wilcoxon test to investigate the null hypothesis that the mean length of cheliceral bases is the same for the two samples of nymph of chigger (Trombicular lipovskyi).

wilcox.test(LENGTH~SAMPLE,nymphs)
## Warning in wilcox.test.default(x = c(104L, 109L, 112L, 114L, 116L, 118L, :
## cannot compute exact p-value with ties
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  LENGTH by SAMPLE
## W = 123.5, p-value = 0.0232
## alternative hypothesis: true location shift is not equal to 0

Conclusions

Reject the null hypothesis. The length of the cheliceral base is significantly longer in nymphs from sample 1 (W= 123.5, df= 24, P= 0.023) than those from sample 2.