data<-read.csv("/Users/nabinwon/Downloads/univ.csv")
head(data)
##   level pass
## 1     1    2
## 2     2    2
## 3     2    1
## 4     1    1
## 5     1    2
## 6     1    2

Null Hypothesis and Alternative Hypothesis

The null hypothesis states that the parent’s education level does not influence their child’s entry to university.

The alternative hypothesis states that the parent’s education level influences their child’s entry to university.

Independent and Dependent Variables

Independent Variable: The parent’s education level Dependent Variable: The child’s entry to college

Drawing the Bar Graphs

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
summary_data<-data %>%
  group_by(level, pass) %>%
  summarise(count=n()) %>%
  mutate(percentage=count/sum(count)*100)
## `summarise()` has grouped output by 'level'. You can override using the
## `.groups` argument.
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.2
ggplot(summary_data, aes(x=factor(level), y=percentage, fill=factor(pass)))+ 
  geom_bar(stat="identity", position="dodge") +
  labs(x="level", y="%", fill="Pass") +
  scale_fill_discrete(labels=c("1","2"))

Analzying the Bar Graphs

Seen by the bar graphs, it can be observed that the independent variable and the dependent variable does not have a correlation, as Level 2 seems to send a higher percentage (or proportion) of their children to university compared to the Level 1 or Level 3.

Chi-Squared Test

library('gmodels')
## Warning: package 'gmodels' was built under R version 4.3.2
CrossTable(data$level,data$pass, chisq =T, # chisq=T를 반드시 지정
           expected= T, dnn=c("The Parent's Education Level","The Child's Entry to College"),prop.r=F, prop.c=F, prop.t=F)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |-------------------------|
## 
##  
## Total Observations in Table:  225 
## 
##  
##                              | The Child's Entry to College 
## The Parent's Education Level |         1 |         2 | Row Total | 
## -----------------------------|-----------|-----------|-----------|
##                            1 |        49 |        40 |        89 | 
##                              |    53.400 |    35.600 |           | 
##                              |     0.363 |     0.544 |           | 
## -----------------------------|-----------|-----------|-----------|
##                            2 |        55 |        27 |        82 | 
##                              |    49.200 |    32.800 |           | 
##                              |     0.684 |     1.026 |           | 
## -----------------------------|-----------|-----------|-----------|
##                            3 |        31 |        23 |        54 | 
##                              |    32.400 |    21.600 |           | 
##                              |     0.060 |     0.091 |           | 
## -----------------------------|-----------|-----------|-----------|
##                 Column Total |       135 |        90 |       225 | 
## -----------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  2.766951     d.f. =  2     p =  0.2507057 
## 
## 
## 

Analysis

Because the p-value is greater than the significance level of 0.05, we cannot dismiss the null hypothesis.