Guest User

Untitled

a guest
Jan 21st, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. Smoking
  2. Cough Non-Smoker Occasional Regular
  3. Yes 266 395 80
  4. No 1037 977 92
  5.  
  6. example <- matrix(c(266,395,80,
  7. 1037,977,92), byrow = T, nrow = 2)
  8.  
  9. dimnames(example) = list(
  10. Cough = c('Yes','No'),
  11. Smoking = c('Non-Smoker','Occasional','Regular')
  12. )
  13.  
  14. coughs = example['Yes',]
  15. patients = apply(example,2,sum)
  16. prop.trend.test(coughs,patients)
  17.  
  18. d = tibble::tribble(
  19. ~cough, ~smoker, ~Weight,
  20. 1, 1, 266,
  21. 0, 1, 1037,
  22. 1, 2, 395,
  23. 0, 2, 977,
  24. 1, 3, 80,
  25. 0, 3, 92
  26. )
  27.  
  28.  
  29. model = lm(cough ~ smoker, data = d, weight = Weight)
  30.  
  31. #See coeffs and ses
  32.  
  33. broom::tidy(model)
  34. test_stat = (0.106)^2/(0.362)^2 #Not the same as book
Add Comment
Please, Sign In to add comment