The table below shows number of student admitted per degree and their social economic status at Arizona University.

Objective

1.0 T o determine if students choice of degree depends on his social economic status.

Hyphothesis

HO: Number of students a dmitted is not dependent on the social economic status of the student.

library(readxl)
contigency_table <- read_excel("C:/Users/USER/Desktop/upwork/contigency_table.xlsx")
contigency<-contigency_table

explore

contigency$SES<-as.factor(contigency$SES)
contigency$caurse<-as.factor(contigency$caurse)
tail(contigency)
## # A tibble: 6 × 3
##   SES   caurse   count
##   <fct> <fct>    <dbl>
## 1 6     science      4
## 2 6     law          3
## 3 6     english      4
## 4 6     commerce     2
## 5 6     medicine     1
## 6 6     other        0
summary(contigency)
##  SES        caurse      count       
##  1:7   arts    :6   Min.   :  0.00  
##  2:7   commerce:6   1st Qu.:  4.00  
##  3:7   english :6   Median : 14.00  
##  4:7   law     :6   Mean   : 19.19  
##  5:7   medicine:6   3rd Qu.: 26.75  
##  6:7   other   :6   Max.   :110.00  
##        science :6

solution

Iam going to use likelihood test method to tackle this problem.

I will compare one model with interaction and the other without the interaction, then find the significance of their differnce,I will use Chisq as the test of likelihood.

condition for this test because it is a poisson distribution:

counts are independent a long the cases

One model is nested on the other model

enrol1<-glm(contigency$count~contigency$caurse*contigency$SES,family = poisson)
enrol2<-glm(contigency$count~contigency$caurse+contigency$SES,family = poisson)
anova(enrol1,enrol2,test="Chisq")
## Analysis of Deviance Table
## 
## Model 1: contigency$count ~ contigency$caurse * contigency$SES
## Model 2: contigency$count ~ contigency$caurse + contigency$SES
##   Resid. Df Resid. Dev  Df Deviance  Pr(>Chi)    
## 1         0       0.00                           
## 2        30     356.42 -30  -356.42 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Recommendation

There diffence is significant(pv<-0.5).Therefore we reject the null hypothesis at alpha =0.05 with a chance of commiting Error Type I

conclusion

We therefore conclude that choice of atudent caurse depends on her social economic status.