Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. structure(list(protein = c(3.763, 11.27, 3.617, 4.315, 5.834,
  2. 5.333, 5.728, 7.107, 7.686, 13.189, 6.618, 8.871, 11.653, 10.595,
  3. 7.232, 6.115, 8.079, 5.208, 4.329, 6.47, 5.121, 10.84, 4.34,
  4. 9.786, 8.352, 4.196, 5.998, 7.23, 7.385, 6.478, 4.837, 6.389,
  5. 4.738, 6.902, 4.488, 6.637, 5.637, 4.992, 3.972, 6.312, 4.838,
  6. 9.912, 6.388, 10.001, 4.179, 5.568, 7.046, 9.254, 5.878, 8.289
  7. ), sex = structure(c(2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L,
  8. 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L,
  9. 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L,
  10. 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L), .Label = c("F", "M"), class = "factor"),
  11. age = c(71, 22, 56, 52, 42, 58, 65, 57, 34, 17, 69, 30, 18,
  12. 34, 38, 33, 28, 66, 63, 39, 60, 27, 69, 16, 29, 49, 47, 34,
  13. 26, 65, 60, 78, 62, 27, 71, 22, 63, 62, 71, 42, 54, 20, 45,
  14. 33, 52, 41, 37, 17, 76, 46), genotype = structure(c(2L, 3L,
  15. 2L, 2L, 3L, 2L, 1L, 3L, 2L, 1L, 1L, 1L, 3L, 1L, 1L, 2L, 1L,
  16. 3L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 3L, 1L, 1L, 2L, 3L, 3L,
  17. 3L, 3L, 1L, 2L, 2L, 1L, 2L, 3L, 2L, 1L, 3L, 1L, 1L, 3L, 2L,
  18. 3L, 3L, 3L), .Label = c("AA", "AC", "CC"), class = "factor")), row.names = c(NA,
  19. -50L), class = "data.frame")
  20.  
  21. fit <- lm(protein~sex+age, data = exam)
  22.  
  23. y <- residuals(fit) + coef(fit)[1] # adding the intercept to the residuals
  24.  
  25. boxplot(y~exam$genotype) # genotype in this example is my variable of interest.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement