Below are the solutions to these exercises on inferential statistics.

#################### # # # Exercise 1 # # # #################### hist(unlist(data["pres"]))

#OR ggplot(data, aes(unlist(data["pres"]))) + geom_histogram()

#################### # # # Exercise 2 # # # #################### qqnorm(unlist(data["pres"])) qqline(unlist(data["pres"]))

#################### # # # Exercise 3 # # # #################### shapiro.test(unlist(data["pres"]))

## ## Shapiro-Wilk normality test ## ## data: unlist(data["pres"]) ## W = 0.81892, p-value < 2.2e-16

#################### # # # Exercise 4 # # # #################### ad.test(unlist(data["pres"]))

## ## Anderson-Darling normality test ## ## data: unlist(data["pres"]) ## A = 33.901, p-value < 2.2e-16

#################### # # # Exercise 5 # # # #################### sh <- apply(data, 1, function(x) shapiro.test(x)$p.value) sum(sh > 0.05)/nrow(data) * 100

## [1] 32.68229

#################### # # # Exercise 6 # # # #################### boxplot(data["pres"])

# OR qplot(y=data["pres"], x= 1, geom = "boxplot")

#OR ggplot(data, aes(x="pres", y=pres))+geom_boxplot()

#################### # # # Exercise 7 # # # #################### grubbs.test(unlist(data$pres))

## ## Grubbs test for one outlier ## ## data: unlist(data$pres) ## G = 3.57030, U = 0.98336, p-value = 0.1299 ## alternative hypothesis: lowest value 0 is an outlier

#################### # # # Exercise 8 # # # #################### grubbs.test(unlist(data["pres"]),two.sided = TRUE)

## ## Grubbs test for one outlier ## ## data: unlist(data["pres"]) ## G.pres8 = 3.57030, U = 0.98336, p-value = 0.2598 ## alternative hypothesis: lowest value 0 is an outlier

#################### # # # Exercise 9 # # # #################### mass_1 <- data$mass[sample(length(data$mass), 14)] mass_2 <- rnorm(14,28,4) wilcox.test(mass_1,mass_2,paired = TRUE)

## ## Wilcoxon signed rank test ## ## data: mass_1 and mass_2 ## V = 71, p-value = 0.2676 ## alternative hypothesis: true location shift is not equal to 0

#################### # # # Exercise 10 # # # #################### wilcox.test(data$pres ~ data$class)

## ## Wilcoxon rank sum test with continuity correction ## ## data: data$pres by data$class ## W = 55414, p-value = 7.559e-05 ## alternative hypothesis: true location shift is not equal to 0

## Leave a Reply