Advertisement
Guest User

Task 3

a guest
Jan 26th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.82 KB | None | 0 0
  1. # Task 3
  2. install.packages('MASS')
  3. library('MASS')
  4. data('birthwt')
  5.  
  6. # 1 for underweigth, 0 for the opposite
  7. wtCategory <- c()
  8.  
  9. for (i in 1:length(birthwt$bwt)) {
  10.   if (birthwt$bwt[i] < 2500) {
  11.     wtCategory <- c(wtCategory, 1)
  12.   } else {
  13.     wtCategory <- c(wtCategory, 0)
  14.   }
  15. }
  16.  
  17. boxplot(birthwt$age ~ wtCategory)
  18.  
  19. underWt <- birthwt$age[which(birthwt$bwt < 2500)]
  20. notUnderWt <- birthwt$age[which(birthwt$bwt >= 2500)]
  21.  
  22. shapiro.test(underWt) # > alpha = 0.05
  23. shapiro.test(notUnderWt) # < alpha = 0.05
  24.  
  25. # the distribution of ones with not underweight is not normal so we can't use Students t test
  26. # we will use the Wilcoxon test
  27. wilcox.test(x = underWt, y = notUnderWt, conf.int = T, conf.level = 0.2, alternative = "greater")
  28.  
  29. # we cannot throw away the hypothesis that younger women give birth to younger babies
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement