Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Task 3
- install.packages('MASS')
- library('MASS')
- data('birthwt')
- # 1 for underweigth, 0 for the opposite
- wtCategory <- c()
- for (i in 1:length(birthwt$bwt)) {
- if (birthwt$bwt[i] < 2500) {
- wtCategory <- c(wtCategory, 1)
- } else {
- wtCategory <- c(wtCategory, 0)
- }
- }
- boxplot(birthwt$age ~ wtCategory)
- underWt <- birthwt$age[which(birthwt$bwt < 2500)]
- notUnderWt <- birthwt$age[which(birthwt$bwt >= 2500)]
- shapiro.test(underWt) # > alpha = 0.05
- shapiro.test(notUnderWt) # < alpha = 0.05
- # the distribution of ones with not underweight is not normal so we can't use Students t test
- # we will use the Wilcoxon test
- wilcox.test(x = underWt, y = notUnderWt, conf.int = T, conf.level = 0.2, alternative = "greater")
- # we cannot throw away the hypothesis that younger women give birth to younger babies
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement