R Markdown

Question 2: Sleep and Phone Use

Scatterplot

library(readxl)
library(ggpubr)
## Loading required package: ggplot2
A4Q2 <- read_excel("C:/Users/wmacklin/Downloads/A4Q2.xlsx")

ggscatter(A4Q2,
          x = "sleep",
          y = "phone",
          add = "reg.line",
          conf.int = TRUE)

### Normality Tests

The Shapiro-Wilk tests were used to determine whether the sleep and phone use variables were normally distributed.

shapiro.test(A4Q2$sleep)
## 
##  Shapiro-Wilk normality test
## 
## data:  A4Q2$sleep
## W = 0.91407, p-value = 8.964e-08
shapiro.test(A4Q2$phone)
## 
##  Shapiro-Wilk normality test
## 
## data:  A4Q2$phone
## W = 0.89755, p-value = 9.641e-09

The Shapiro-Wilk tests showed that both variables were not normally distributed because both p-values were less than 0.05. Therefore, a Spearman correlation test was used.

Spearman Correlation Test

cor.test(A4Q2$sleep,
         A4Q2$phone,
         method = "spearman")
## 
##  Spearman's rank correlation rho
## 
## data:  A4Q2$sleep and A4Q2$phone
## S = 908390, p-value < 2.2e-16
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##        rho 
## -0.6149873

The Spearman correlation test showed a significant negative correlation between hours of sleep and hours of phone use, ρ = -0.615, p < 0.001. This indicates that as phone use increases, hours of sleep tend to decrease.