Rishabh Kumar Raikwar
Research Question- “Is there a difference in the grades of students
who attended lectures regularly compared to those who didn’t ?
mydata <- read.csv("C:/Users/Rishabh/Documents/Homework 1/students/student-mat.csv" ,header = TRUE)
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
library(ggplot2)
library(psych)
##
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
library(effectsize)
##
## Attaching package: 'effectsize'
## The following object is masked from 'package:psych':
##
## phi
head(mydata)
## Gender age studytime absences G1 G2 G3 TotalG
## 1 1 17 2 4 5 5 6 16
## 2 1 17 2 6 6 5 6 17
## 3 2 17 1 16 6 5 5 16
## 4 1 16 2 12 5 5 5 15
## 5 2 17 2 4 6 5 6 17
## 6 2 18 2 8 3 5 5 13
Unit of observation: A student
Sample size: 357
Gender: 1 for Female, 2 for Male
age: age of student in years
studytime: Number of hours studied per day
absences: Number of days absent in college
G1: Grade for subject 1
G2: Grade for subject 2
G3: Grade for subject 3
TotalG: Total grade
mydata$GenderNew <- factor(mydata$Gender,
levels = c(1,2),
labels = c("F","M"))
summary(mydata[, 2:ncol(mydata)])
## age studytime absences G1
## Min. :15.00 Min. :1.000 Min. : 0.000 Min. : 3.00
## 1st Qu.:16.00 1st Qu.:1.000 1st Qu.: 2.000 1st Qu.: 9.00
## Median :17.00 Median :2.000 Median : 4.000 Median :11.00
## Mean :16.66 Mean :2.042 Mean : 6.317 Mean :11.27
## 3rd Qu.:18.00 3rd Qu.:2.000 3rd Qu.: 8.000 3rd Qu.:14.00
## Max. :22.00 Max. :4.000 Max. :75.000 Max. :19.00
## G2 G3 TotalG GenderNew
## Min. : 5.00 Min. : 4.00 Min. :13.00 F:185
## 1st Qu.: 9.00 1st Qu.: 9.00 1st Qu.:27.00 M:172
## Median :11.00 Median :11.00 Median :34.00
## Mean :11.36 Mean :11.52 Mean :34.15
## 3rd Qu.:14.00 3rd Qu.:14.00 3rd Qu.:41.00
## Max. :19.00 Max. :20.00 Max. :58.00
# Creating new variable attendance where those students who are absent more than 4 days gets No and other group gets Yes
mydata$attendance <- ifelse(mydata$absences > 4, 0, 1)
mydata$attendancenew <- factor(mydata$attendance,
levels = c(0,1),
labels= c("Not Regular","Regular"))
shapiro_test_result <- shapiro.test(mydata$TotalG)
print(shapiro_test_result)
##
## Shapiro-Wilk normality test
##
## data: mydata$TotalG
## W = 0.98738, p-value = 0.003399
Total Grade is not normally distributed, so Wilcoxon Rank Sum Test
is conducted.
H0 : Mean Total Grade of students who attended lectures and those
who didn’t are equal.
H1 : Mean Total Grade of students who attended lectures and those
who didn’t are not equal.
describeBy(mydata$TotalG, g= mydata$attendancenew)
##
## Descriptive statistics by group
## group: Not Regular
## vars n mean sd median trimmed mad min max range skew
## X1 1 151 32.36 9.73 32 31.88 10.38 13 56 43 0.41
## kurtosis se
## X1 -0.3 0.79
## ----------------------------------------------------
## group: Regular
## vars n mean sd median trimmed mad min max range skew
## X1 1 206 35.47 8.87 35 35.33 10.38 16 58 42 0.15
## kurtosis se
## X1 -0.71 0.62
wilcox.test(mydata$TotalG ~ mydata$attendance,
paired = FALSE,
correct = FALSE,
exact = FALSE,
alternative = "two.sided")
##
## Wilcoxon rank sum test
##
## data: mydata$TotalG by mydata$attendance
## W = 12456, p-value = 0.001296
## alternative hypothesis: true location shift is not equal to 0
We reject H0 at alpha = 5%, p < 0.001
effectsize(wilcox.test(mydata$TotalG ~ mydata$attendancenew,
paired= FALSE,
correct = FALSE,
exact= FALSE,
alterantive = "two.sided"))
## r (rank biserial) | 95% CI
## ----------------------------------
## -0.20 | [-0.31, -0.08]
interpret_rank_biserial(0.20)
## [1] "medium"
## (Rules: funder2019)
Conclusion: Based on the sample data, we found that there is a
difference between grades of students who attended lectures regularly
compared to those who didn’t (p <0.001) - students who attended
lectures regularly score higher, the difference is medium (r=0.20).