#1.1 Data
source: https://online.stat.psu.edu/stat200/datasets (file:Examdata.xlsx)
At the Penn University, they wanted to compare the student scores (unknown subject) at Quizzes (average of multiple quizes) during the year (maximum 100 points) and the score at the Final exam (maximum 100 points). 50 random students were selected.
Can we say that the average scores obtained at Quizzes during the year and Final exam are different? If so, where do the students perform better?
Examdata_1_ <- read.table("/cloud/project/Quiz avg vs Final/Examdata (1).csv", header = TRUE, sep = ",", dec = ".")
head(Examdata_1_)
## ID Quiz_Average Final
## 1 1 84.440 90
## 2 2 96.633 100
## 3 3 74.809 67
## 4 4 79.108 80
## 5 5 95.490 92
## 6 6 91.623 78
Description:
ID: Student ID -
Quiz Average: Result at Quizes during the year -
Final: Result at Final exam -
summary(Examdata_1_)
## ID Quiz_Average Final
## Min. : 1.00 Min. :63.07 Min. : 37.00
## 1st Qu.:13.25 1st Qu.:78.05 1st Qu.: 67.00
## Median :25.50 Median :84.28 Median : 77.00
## Mean :25.50 Mean :83.91 Mean : 75.16
## 3rd Qu.:37.75 3rd Qu.:92.09 3rd Qu.: 82.00
## Max. :50.00 Max. :99.20 Max. :100.00
#1.2. Analysis
We configure the historgram to see the distribution of differences between means.
Examdata_1_$Difference <- Examdata_1_$Quiz_Average - Examdata_1_$Final
library(ggplot2)
ggplot(Examdata_1_, aes(x=Difference))+geom_histogram(binwidth = 4, color="black") + xlab("Differences")
We perform the Shapiro-Wilk test to check whether the differences between means are normally distributed.
shapiro.test(Examdata_1_$Difference)
##
## Shapiro-Wilk normality test
##
## data: Examdata_1_$Difference
## W = 0.9853, p-value = 0.7844
We cannot reject that the differences between means are normally distributed (p>0.05), therefore we can continue with a parametric test.
library(psych)
##
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
describe(Examdata_1_[ , -1])
## vars n mean sd median trimmed mad min max range skew
## Quiz_Average 1 50 83.91 9.81 84.28 84.57 11.53 63.07 99.2 36.13 -0.39
## Final 2 50 75.16 12.11 77.00 75.78 10.38 37.00 100.0 63.00 -0.64
## Difference 3 50 8.75 9.92 9.06 8.97 8.15 -14.65 28.7 43.35 -0.18
## kurtosis se
## Quiz_Average -0.89 1.39
## Final 0.64 1.71
## Difference -0.40 1.40
We have paired samples so we perform a paired t-test.
t.test(Examdata_1_$Quiz_Average, Examdata_1_$Final, paired = TRUE, alternative = "two.sided")
##
## Paired t-test
##
## data: Examdata_1_$Quiz_Average and Examdata_1_$Final
## t = 6.2375, df = 49, p-value = 1.006e-07
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## 5.929489 11.566191
## sample estimates:
## mean difference
## 8.74784
Based on p value(<0.01) we reject the H0. There are differences in means.
library(effectsize)
##
## Attaching package: 'effectsize'
## The following object is masked from 'package:psych':
##
## phi
cohens_d(Examdata_1_$Quiz_Average, Examdata_1_$Final, paired = TRUE, alternative = "two.sided")
## Cohen's d | 95% CI
## ------------------------
## 0.88 | [0.55, 1.21]
interpret_cohens_d(0.88, rules="sawilowsky2009")
## [1] "large"
## (Rules: sawilowsky2009)
This was hypothesis testing with a parametric test. Now we are also going to perform a non-parametric test. With non-paramtetric test we will check whether there are differences between distribution locations, instead of differences between means.
wilcox.test(Examdata_1_$Quiz_Average, Examdata_1_$Final, paired=TRUE, correct = FALSE, exact= FALSE, alternative = "two.sided")
##
## Wilcoxon signed rank test
##
## data: Examdata_1_$Quiz_Average and Examdata_1_$Final
## V = 1134, p-value = 1.644e-06
## alternative hypothesis: true location shift is not equal to 0
We reject the H0 (p<0.01). There are differences between distribution locations on the population.
#1.3 Conclusion
Since the assumptions of normality of differences was met (p=0.7844), the more appropriate test to use is the parametric test (t.test).
Based on sample data we found the difference between average points received at Quizzes (mean=83.91) and average points received at the Final exam (mean=75.16). The difference is statistically significant at p<0.01 (effect size is large, d = 0.88).
We can conclude that average scores obtained at Quizzes during the year and Final exam are different. Students on average perform better at Quizzes during the year than at the Final exam.