# Pearson’s Chi-Squared Test

Solution

3.

a, Null hypothesis: there is no association between gender and grade.

Alternative hypothesis: there is a significant association, they are not independet.

Chi-squred test:

Test number is sum of (observed-expected)2/expected

degree of freedom is (row-1)*(column-1)

Based on these two the critical number could be looked up in a table or Excel could be used to get the p-value.

In r:

x <- matrix(c(18, 2, 16, 4), ncol = 2)

 >chisq.test(x) Pearson’s Chi-squared test with Yates’ continuity correction data:  x X-squared = 0.19608, df = 1, p-value = 0.6579 Warning message: In chisq.test(x) : Chi-squared approximation may be incorrect

Fisher’s exact p-value is (a+b)!(c+d)!(a+c)!(b+d)!/a!b!c!d!n!

 >fisher.test(x) Fisher’s Exact Test for Count Data data:  x p-value = 0.6614 alternative hypothesis: true odds ratio is not equal to 1 95 percent confidence interval: 0.2730362 27.4840093 sample estimates: odds ratio 2,205556

Neither Chi-squared, nor Fisher’s exact tests are significant, as their p-values are aboev 0.05, so we cannot reject the null hypothesis, there is no significant associations between the categorical variables, they are independent.

b, The Fisher’s exact is better as for Chi-squared minimum 5 observation needed inat least 80% of all cells, to fulfill criteria.

Their p-values are not the same, but neither of them is significant so we can draw the same conculsion. In case of very differenct p-values the Chi-squared is more powerful as it is a parametric test, buti f it cannot be used (like here) the Fisher’s exact is reliable.

Their p-values are not the same, but neither of them is significant so we can draw the same conculsion. In case of very differenct p-values the Chi-squared is more powerful as it is a parametric test, buti f it cannot be used (like here) the Fisher’s exact is reliable.

The calculations by hand could differ a bit because of rounding, however it is good to now the background calculations and it is easier to understand the test itself.