# input sleep data
<- data.frame(id = 1:10,
data.sleep drug = c(6.1, 6.0, 8.2, 7.6, 6.5, 5.4, 6.9, 6.7, 7.4, 5.8),
placebo = c(5.2, 7.9, 3.9, 4.7, 5.3, 7.4, 4.2, 6.1, 3.8, 7.3))
Exercises
Exercise 1 (Wilcoxon signed rank test) Try repeating the calculations for the Wilcoxon signed rank test. Could you check if the median sleeping time without taking the drug is significantly different than 6 h?
Below is the code to create the data.
Exercise 2 (Wilcoxon rank sum test)
You’ve collected more data on the newborn babies born to smokers and non-smokers. Is the enough evidence to reject the null hypothesis of the difference between the medians of the two groups equals to zero? Use the code below to input new data.
# input babies weights
<- c(3.99, 3.89, 3.6, 3.73, 3.31, 3.7, 4.08, 3.61, 3.83, 3.41, 4.13, 3.36, 3.54, 3.51, 2.71)
bw.nonsmokers <- c(3.18, 2.74, 2.9, 3.27, 3.65, 3.42, 3.23, 2.86, 3.6, 3.65, 3.69, 3.53, 2.38, 2.34) bw.smokers
Exercise 3 (Kruskall Wallis) Can you double-check your calculations using Kruskall-Wallis test instead via kruskal-test()
function? Would you expect to get different or similar results? And finally, imagine that you’ve repeated the experiment again, this time collecting data for three groups, non-smokers, occasional smokers and regular smokers. Is there enough evidence to reject the null hypothesis of each group having the same distribution of values in the population?
Data data are below.
# input babies weights
<- c(3.99, 3.89, 3.6, 3.73, 3.31, 3.7, 4.08, 3.61, 3.83, 3.41, 4.13, 3.36, 3.54, 3.51, 2.71)
bw.nonsmokers <- c(3.18, 2.74, 2.9, 3.27, 3.65, 3.42, 3.23, 2.86, 3.6, 3.65, 3.69, 3.53, 2.38, 2.34)
bw.smokers <- c(3.65, 3.53, 2.34, 3.70, 3.42, 2.71, 3.83, 3.60, 3.18, 3.65) bw.occsmokers