An American roulette wheel contains 38 slots: 18 red, 18 black, and 2 green. A casino has purchased a new wheel and they want to know if there is any evidence that the wheel is unfair. They spin the wheel 150 times and it lands on red 66 times, black 74 times, and green 10 times.
Comment: This is a chi-square test where we want to see if the wheel lands on each color with the expected frequency (according to the expected/right percentage). Therefore, this is a chi-square goodness of fit test. We are trying to see if the data correspond to expected percentages.
Ho: p_red= 18/38 p_black= 18/38 p_green= 2/38 (the wheel is fair)
Ha: At least one of probabilities (or percentages) are different from what we expect (the wheel is unfair)
wheels_spin <- c(66, 74, 10)
probvector <- c(18/38, 18/38, 2/38)
Are all the expected counts greater than or equal to 5?
chisq.test(wheels_spin, p= probvector)$expected
## [1] 71.052632 71.052632 7.894737
Yes, all the expected counts are >=5. Therefore, we can apply the test in its original form (without any corrections)
# correct= False because we showed that all the expected counts are >=5
chisq.test(wheels_spin, p= probvector, correct= FALSE)
##
## Chi-squared test for given probabilities
##
## data: wheels_spin
## X-squared = 1.043, df = 2, p-value = 0.5936
p-value 0.5936 > 0.05(alpha)
therefore, we fail to reject Ho.The data does NOT give us sufficient evidence to support the idea that the wheel is unfair and not corresponding to the expected percentages.
Ho: The personality characteristics and the profession are independent
Ha: The personality characteristics and the profession are dependent (the personality characteristics influence the profession)
2)Enter the data in R
matrix_personality_character= matrix(c(62,45,68,94,56,81), nrow=3, byrow=TRUE, dimnames= list(c("Clergy","Medical Doctor","Lawyer"),c("Extroverted","Introverted")))
matrix_personality_character
## Extroverted Introverted
## Clergy 62 45
## Medical Doctor 68 94
## Lawyer 56 81
Is the validity assumption met? (Are all expected counts >= 5?)
chisq.test(matrix_personality_character)$expected
## Extroverted Introverted
## Clergy 49.01970 57.98030
## Medical Doctor 74.21675 87.78325
## Lawyer 62.76355 74.23645
The expected counts are above 5; thus, the assumption for the validity of the test is met. No need for correction (correct= FALSE)
chisq.test(matrix_personality_character, correct = FALSE)
##
## Pearson's Chi-squared test
##
## data: matrix_personality_character
## X-squared = 8.6492, df = 2, p-value = 0.01324
The p-value is less than alpha (0.05); therefore, we reject Ho in favor of Ha. So, we can claim that some personality characteristics are more heavily associated to certain professions and are therefore dependent.
Because we rejected Ho (this next analysis DOES NOT make sense when we do NOT reject Ho), we can ask the following question: Which profession is more closely related to extrovert and introvert personalities?
chisq.test(matrix_personality_character, correct = FALSE)$residuals
## Extroverted Introverted
## Clergy 1.8539552 -1.7046859
## Medical Doctor -0.7216263 0.6635253
## Lawyer -0.8537304 0.7849932
We can see that clergy and extrovert have the strongest positive contribution. Therefore, we can conclude that clergies have the strongest personality association to extrovert characteristics and the weakest personality associating to introvert characteristics.
Computing Cramer’s V
chi_square_value = unname(chisq.test(matrix_personality_character, correct = FALSE)$statistic)
sqrt(chi_square_value/(sum (matrix_personality_character)*min (ncol(matrix_personality_character)-1,nrow(matrix_personality_character)-1)))
## [1] 0.1459569
The value of Cramer’s V indicates that clergy and extrovert have a weak to moderate association.
WE WILL NOT DO THIS EXERCISE NOW !!!
We will do it when practicing for the final exam.