Rishabh Kumar Raikwar

Research ques 1.Is there a correlation between scores achieved in mentioned subjects?

Research ques 2. Is there relationship between gender and whether or not students completed test preparation?

library(Hmisc)
## 
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
## 
##     format.pval, units
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:Hmisc':
## 
##     src, summarize
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(psych)
## 
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
## The following object is masked from 'package:Hmisc':
## 
##     describe
library(effectsize)
## 
## Attaching package: 'effectsize'
## The following object is masked from 'package:psych':
## 
##     phi
library(car)
## Loading required package: carData
## 
## Attaching package: 'car'
## The following object is masked from 'package:psych':
## 
##     logit
## The following object is masked from 'package:dplyr':
## 
##     recode
mydata <- read.csv("C:/Users/Rishabh/Documents/Homework 1/students/StudentsPerformance.csv" ,header = TRUE)
head(mydata)
##   gender test.preparation.course math.score reading.score
## 1      0                    none         72            72
## 2      0               completed         69            90
## 3      0                    none         90            95
## 4      1                    none         47            57
## 5      1                    none         76            78
## 6      0                    none         71            83
##   writing.score
## 1            74
## 2            88
## 3            93
## 4            44
## 5            75
## 6            78

Description of data set

Unit of observation: A student

Sample size: 1000

Gender: 0 for Female, 1 for Male

test.preparation.course: whether student has completed preparation course or not

math.score : score in math

reading.score : score in reading

writing.score : score in writing

Data source: https://www.kaggle.com

#Making factors for gender
mydata$GenderNew <- factor(mydata$gender,
                        levels = c(0,1),
                        labels = c("Female","Male"))
summary(mydata[,-c(1,2)])
##    math.score     reading.score    writing.score     GenderNew  
##  Min.   :  0.00   Min.   : 17.00   Min.   : 10.00   Female:518  
##  1st Qu.: 57.00   1st Qu.: 59.00   1st Qu.: 57.75   Male  :482  
##  Median : 66.00   Median : 70.00   Median : 69.00               
##  Mean   : 66.09   Mean   : 69.17   Mean   : 68.05               
##  3rd Qu.: 77.00   3rd Qu.: 79.00   3rd Qu.: 79.00               
##  Max.   :100.00   Max.   :100.00   Max.   :100.00
scatterplotMatrix(mydata[,-c(1,2,6,7)], smooth = FALSE)

rcorr(as.matrix(mydata[,-c(1,2,6,7)]),
      type = "pearson")
##               math.score reading.score writing.score
## math.score          1.00          0.82          0.80
## reading.score       0.82          1.00          0.95
## writing.score       0.80          0.95          1.00
## 
## n= 1000 
## 
## 
## P
##               math.score reading.score writing.score
## math.score                0             0           
## reading.score  0                        0           
## writing.score  0          0

H0: ρ reading,writing = 0

H1: ρ reading,writing ≠ 0

Linear relationship between Reading and Writing is positive and very strong (r=0.95)

We reject H0 at p < 0.001

#Creating new variable Test_Completed where those students who did'nt complete gets No, others get Yes. 
mydata$Test_Completed<- factor(mydata$test.preparation.course,
                                levels = c("none","completed"),
                                labels = c("No","Yes")
                                )
results <- chisq.test(mydata$GenderNew, mydata$Test_Completed,
                      correct = TRUE)
results
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  mydata$GenderNew and mydata$Test_Completed
## X-squared = 0.015529, df = 1, p-value = 0.9008

H0: There is no association between gender and whether or not students completed test preparation.

H1: There is association between gender and whether or not students completed test preparation.

We cannot reject H0, because p > 0.05

#showing empirical frequency
addmargins(results$observed)
##                 mydata$Test_Completed
## mydata$GenderNew   No  Yes  Sum
##           Female  334  184  518
##           Male    308  174  482
##           Sum     642  358 1000
#showing expected frequency
round(results$expected,2)
##                 mydata$Test_Completed
## mydata$GenderNew     No    Yes
##           Female 332.56 185.44
##           Male   309.44 172.56
# calculating standardized residual
round(results$res,2)
##                 mydata$Test_Completed
## mydata$GenderNew    No   Yes
##           Female  0.08 -0.11
##           Male   -0.08  0.11

Since standardized residual is < 1.96, it is not significant.

addmargins(round(prop.table(results$observed),3))
##                 mydata$Test_Completed
## mydata$GenderNew    No   Yes   Sum
##           Female 0.334 0.184 0.518
##           Male   0.308 0.174 0.482
##           Sum    0.642 0.358 1.000

Out of 1000 students, 18.4% females completed test preparation.

addmargins(round(prop.table(results$observed,1),3),2)
##                 mydata$Test_Completed
## mydata$GenderNew    No   Yes   Sum
##           Female 0.645 0.355 1.000
##           Male   0.639 0.361 1.000

Out of all females, 35.5% completed test preparation.

addmargins(round(prop.table(results$observed,2),3),1)
##                 mydata$Test_Completed
## mydata$GenderNew    No   Yes
##           Female 0.520 0.514
##           Male   0.480 0.486
##           Sum    1.000 1.000

Out of all students who completed test preparation, 51.4% were females.

effectsize::cramers_v(mydata$GenderNew,mydata$Test_Completed)
## Cramer's V (adj.) |       95% CI
## --------------------------------
## 0.00              | [0.00, 1.00]
## 
## - One-sided CIs: upper bound fixed at [1.00].
interpret_cramers_v(0)
## [1] "tiny"
## (Rules: funder2019)

Based on Pearson Chi2 test, we found out there is no relationship between gender and whether or not students completed test preparation