Is there a relationship between hours of sleep and hours of phone use?
q2 <- read_excel("A4Q2.xlsx")
head(q2)
## # A tibble: 6 × 2
## sleep phone
## <dbl> <dbl>
## 1 9.03 1.78
## 2 6.76 6.62
## 3 9.18 0.289
## 4 7.20 3.33
## 5 3 10
## 6 6.71 4.24
A Spearman rank-order correlation was selected because hours of sleep and hours of phone use are continuous variables, but both variables violated the normality assumption.
shapiro.test(q2$sleep)
##
## Shapiro-Wilk normality test
##
## data: q2$sleep
## W = 0.91407, p-value = 8.964e-08
shapiro.test(q2$phone)
##
## Shapiro-Wilk normality test
##
## data: q2$phone
## W = 0.89755, p-value = 9.641e-09
The Shapiro-Wilk tests were statistically significant for both variables, indicating that the data were not normally distributed.
cor.test(q2$sleep, q2$phone, method = "spearman", exact = FALSE)
##
## Spearman's rank correlation rho
##
## data: q2$sleep and q2$phone
## S = 908390, p-value < 2.2e-16
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## -0.6149873
A Spearman rank-order correlation showed a statistically significant moderate negative relationship between hours of sleep and hours of phone use, rs = -.615, p < .001. This means that, in this dataset, greater phone use was associated with fewer hours of sleep.