Advertisement
897bhgy

Untitled

Jul 13th, 2023
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.97 KB | Source Code | 0 0
  1. set.seed(123)
  2.  
  3. # Simulating hair and eye color data
  4. hair_color <- sample(c("Black", "Blonde", "Brown"), size = 100, replace = TRUE)
  5. eye_color <- sample(c("Blue", "Brown", "Green"), size = 100, replace = TRUE)
  6. df <- data.frame(hair_color, eye_color)
  7.  
  8. # Conducting Chi-Squared test to check for an association between hair color and eye color
  9. # H0: There is no association between hair color and eye color
  10. # H1: There is an association between hair color and eye color
  11. result <- chisq.test(df$hair_color, df$eye_color)
  12.  
  13. # Print the result of the test
  14. print(result)
  15.  
  16. # If the p-value is less than the significance level (commonly 0.05), we reject the null hypothesis.
  17. # This means we have evidence to suggest there is an association between hair color and eye color.
  18. # If the p-value is greater than the significance level, we fail to reject the null hypothesis.
  19. # This means we do not have sufficient evidence to suggest there is an association between hair color and eye color.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement