Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set.seed(123)
- # Simulating hair and eye color data
- hair_color <- sample(c("Black", "Blonde", "Brown"), size = 100, replace = TRUE)
- eye_color <- sample(c("Blue", "Brown", "Green"), size = 100, replace = TRUE)
- df <- data.frame(hair_color, eye_color)
- # Conducting Chi-Squared test to check for an association between hair color and eye color
- # H0: There is no association between hair color and eye color
- # H1: There is an association between hair color and eye color
- result <- chisq.test(df$hair_color, df$eye_color)
- # Print the result of the test
- print(result)
- # If the p-value is less than the significance level (commonly 0.05), we reject the null hypothesis.
- # This means we have evidence to suggest there is an association between hair color and eye color.
- # If the p-value is greater than the significance level, we fail to reject the null hypothesis.
- # 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