Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1.  
  2. # Exercise 1
  3.  
  4. To investigate the relations between hair color and eye color, the hair color and eye color of 5383 was recorded. The data are given in Table 1. Eye color is encoded by the values 1 (Light) and 2 (Dark), and hair color by 1 (Fair/red), 2 (Medium), and 3 (Dark/black). By dividing the numbers in the table by 5383, the tble is turned into a joint probability distribution for random variables X (hair color) taking values 1 to 3 and Y (eye color) taking values 1 and 2.
  5.  
  6. ```{r echo=FALSE}
  7. co <- matrix(c(1168,573,825,1312,305,1200),nrow=2)
  8. rownames(co)<-c("Light","Dark")
  9. colnames(co)<-c("Fair/Red","Medium","Dark/black")
  10. dimnames(co)<-list("Eye color"=rownames(co),"Hair color"=colnames(co))
  11.  
  12. library(knitr)
  13. library(kableExtra)
  14. kable(co, format = "latex", caption = "Relation between hair color and eye color.", booktabs = T) %>%
  15. kable_styling(latex_options = c("HOLD_position")) %>%
  16. add_header_above(c(" ", "Hair color" = 3), bold = T) %>%
  17. group_rows(index = c("Eye color" = 2))
  18. ```
  19.  
  20.  
  21.  
  22.  
  23. (a) Determine the joint and marginal probability distributions of $X$ and $Y$.
  24.  
  25. ```{r echo=FALSE}
  26. co <- matrix(c(0.217,0.106,0.323,0.153,0.244,0.397,0.057,0.223,0.280,0.427,0.573,1),nrow=3)
  27. rownames(co)<-c("Light","Dark","Marginal")
  28. colnames(co)<-c("Fair/Red","Medium","Dark/black","Marginal")
  29. dimnames(co)<-list("Eye color"=rownames(co),"Hair color"=colnames(co))
  30.  
  31. library(knitr)
  32. library(kableExtra)
  33. kable(co, format = "latex", caption = "Joint and marginal probability distribution of X and Y", booktabs = T) %>%
  34. kable_styling(latex_options = c("HOLD_position")) %>%
  35.  
  36. add_header_above(c(" ", "Hair color" = 3), bold = T) %>%
  37. group_rows(index = c("Eye color" = 2))
  38. ```
  39.  
  40.  
  41. (b) Find out whether $X$ and $Y$ are dependent or independent.
  42.  
  43. For $X$ and $Y$ to be independent it has to fulfill:
  44. $$
  45. P(X \leq a, Y \leq b) = P(X \leq a) P(X \leq b)
  46. $$
  47. We know that:
  48. $$
  49. P(X=1, Y=1) = \frac{1168}{5383} \neq \frac{1168+573}{5383} \cdot \frac{1168+825+305}{5383}
  50. $$
  51. Therefore $X$ and $Y$ are dependent.
  52.  
  53. *This is Exercise 9.7 in @dekking2005.*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement