This document presents the results of the chi-squared test for hair and eye color and binomial tests for number preferences among students and baseball players. These analyses help us understand patterns and preferences in the given data.
This section addresses the chi-squared test to explore the association between hair and eye color.
# Creating the data matrix for hair and eye color
hair_eye_color <- matrix(c(68, 20, 15, 5,
119, 84, 54, 29,
26, 17, 14, 14,
7, 94, 10, 16),
nrow = 4, byrow = TRUE,
dimnames = list(Hair = c("Black", "Brown", "Red", "Blond"),
Eye = c("Brown", "Blue", "Hazel", "Green")))
# Perform the chi-squared test
chi_test <- chisq.test(hair_eye_color)
# Display the test results
chi_test
##
## Pearson's Chi-squared test
##
## data: hair_eye_color
## X-squared = 138.29, df = 9, p-value < 2.2e-16
This section explores whether there is a statistically significant preference for the number ‘7’ among students and baseball players.
# Data for students and baseball players
students_n <- 568
students_x <- 42
baseball_n <- 182
baseball_x <- 25
# Binomial test for students
binom_test_students <- binom.test(students_x, students_n, p = 0.05)
# Binomial test for baseball players
binom_test_baseball <- binom.test(baseball_x, baseball_n, p = 0.05)
# Display the test results for students
print("Binomial Test Result for Students:")
## [1] "Binomial Test Result for Students:"
print(binom_test_students)
##
## Exact binomial test
##
## data: students_x and students_n
## number of successes = 42, number of trials = 568, p-value = 0.01206
## alternative hypothesis: true probability of success is not equal to 0.05
## 95 percent confidence interval:
## 0.05380879 0.09863843
## sample estimates:
## probability of success
## 0.07394366
# Display the test results for baseball players
print("Binomial Test Result for Baseball Players:")
## [1] "Binomial Test Result for Baseball Players:"
print(binom_test_baseball)
##
## Exact binomial test
##
## data: baseball_x and baseball_n
## number of successes = 25, number of trials = 182, p-value = 5.012e-06
## alternative hypothesis: true probability of success is not equal to 0.05
## 95 percent confidence interval:
## 0.09090711 0.19606325
## sample estimates:
## probability of success
## 0.1373626
Before conducting the chi-squared and binomial tests, it is essential to verify that the assumptions underlying these tests are met. For the chi-squared test, the assumption is that the samples are independent and that the observed and expected frequencies in each category are sufficiently large (typically at least 5). For the binomial tests, the trials are assumed to be independent and identically distributed.
By verifying these conditions, we ensure the reliability of our statistical conclusions.
In conclusion, the chi-squared test shows significant results, suggesting a strong association between hair and eye color. Similarly, the binomial tests indicate a statistically significant preference for the number ‘7’ among both students and baseball players. These findings provide valuable insights into the characteristics and preferences of the studied populations.
MA2612_Lab2_Assignment.Rmd.This setup ensures your document includes all necessary components for your assignment, formatted correctly for knitting in RStudio. If you encounter any issues during this process, please feel free to ask for further assistance.