DatasetA <- read_excel("/Users/asfia/Desktop/DatasetA.xlsx")
mean(DatasetA$StudyHours); sd(DatasetA$StudyHours)
## [1] 6.135609
## [1] 1.369224
mean(DatasetA$ExamScore); sd(DatasetA$ExamScore)
## [1] 90.06906
## [1] 6.795224
Interpretation: For Research Question 1, the Independent Variable is Study Hours and the Dependent Variable is Exam Score. The average study time was approximately 5 hours (\(M = 4.97, SD = 1.37\)), while the average exam score was 90% (\(M = 90.07, SD = 6.80\)).
shapiro.test(DatasetA$StudyHours)
##
## Shapiro-Wilk normality test
##
## data: DatasetA$StudyHours
## W = 0.99388, p-value = 0.9349
shapiro.test(DatasetA$ExamScore)
##
## Shapiro-Wilk normality test
##
## data: DatasetA$ExamScore
## W = 0.96286, p-value = 0.006465
hist(DatasetA$StudyHours, main="Histogram of Study Hours", col="lightblue", breaks=20)
hist(DatasetA$ExamScore, main="Histogram of Exam Scores", col="lightgreen", breaks=20)
Interpretation: We used Shapiro-Wilk tests and
Histograms to check for normality. While Study Hours was normal, the
Exam Score failed the normality test (\(p = 0.006\)) and the histogram shows a
left-skewed distribution. Because one variable is not normal, we must
use the Spearman Rank Correlation.
cor.test(DatasetA$StudyHours, DatasetA$ExamScore, method = "spearman")
## Warning in cor.test.default(DatasetA$StudyHours, DatasetA$ExamScore, method =
## "spearman"): Cannot compute exact p-value with ties
##
## Spearman's rank correlation rho
##
## data: DatasetA$StudyHours and DatasetA$ExamScore
## S = 16518, p-value < 2.2e-16
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## 0.9008825
ggscatter(DatasetA, x = "StudyHours", y = "ExamScore", add = "reg.line",
xlab = "Study Hours", ylab = "Exam Score", title = "Study vs Exam")
Interpretation: There is a strong positive
correlation (\(\rho = 0.90, p <
0.001\)) between study hours and exam scores. The scatterplot
shows a clear upward trend with a tight fit to the regression line,
indicating that more study time leads to higher scores.
DatasetB <- read_excel("/Users/asfia/Desktop/DatasetB.xlsx")
mean(DatasetB$ScreenTime); sd(DatasetB$ScreenTime)
## [1] 5.063296
## [1] 2.056833
mean(DatasetB$SleepingHours); sd(DatasetB$SleepingHours)
## [1] 6.938459
## [1] 1.351332
Interpretation: For Research Question 2, the Independent Variable is Screen Time and the Dependent Variable is Sleeping Hours. Average daily screen time was 5 hours (\(M = 5.06, SD = 2.06\)), with an average of 7 hours of sleep (\(M = 6.94, SD = 1.35\)).
shapiro.test(DatasetB$ScreenTime)
##
## Shapiro-Wilk normality test
##
## data: DatasetB$ScreenTime
## W = 0.90278, p-value = 1.914e-06
shapiro.test(DatasetB$SleepingHours)
##
## Shapiro-Wilk normality test
##
## data: DatasetB$SleepingHours
## W = 0.98467, p-value = 0.3004
hist(DatasetB$ScreenTime, main="Histogram of Screen Time", col="pink", breaks=20)
hist(DatasetB$SleepingHours, main="Histogram of Sleeping Hours", col="lightyellow", breaks=20)
Interpretation: The Screen Time
variable failed the normality test significantly (\(p < 0.001\)) and its histogram is
right-skewed. Because this variable is not normally distributed, the
Spearman Rank Correlation is the appropriate
method.
cor.test(DatasetB$ScreenTime, DatasetB$SleepingHours, method = "spearman")
##
## Spearman's rank correlation rho
##
## data: DatasetB$ScreenTime and DatasetB$SleepingHours
## S = 259052, p-value = 3.521e-09
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## -0.5544674
ggscatter(DatasetB, x = "ScreenTime", y = "SleepingHours", add = "reg.line",
xlab = "Screen Time", ylab = "Sleeping Hours", title = "Phone vs Sleep")
Interpretation: There is a moderate negative
correlation (\(\rho = -0.55, p <
0.001\)) between screen time and sleep. The downward trend in the
scatterplot shows that as phone usage increases, total sleep hours tend
to decrease.