library(readxl)
library(ggpubr)
## Loading required package: ggplot2
library(rmarkdown)
phone <- read_excel("phone.xlsx")
ggscatter(
  data = phone,
  x = "phone",
  y = "sleep",
  add = "reg.line",
  xlab = "Phone (Hours)",
  ylab = "Sleep (Hours)"
)

#2. Scatterplot created.

#3. Scatterplot interpretation.

The relationship is linear. The relationship is negative. The relationship is moderate. The are minor outliers.

Data reflects negative linear relationship requiring pearson.

  1. Descriptive Stats
mean(phone$phone)
## [1] 3.804609
sd(phone$phone)
## [1] 2.661866
median(phone$phone)
## [1] 3.270839
mean(phone$sleep)
## [1] 7.559076
sd(phone$sleep)
## [1] 1.208797
median(phone$sleep)
## [1] 7.524099

#5. Phone Histogram

hist(phone$phone,
     main = "Phone Use",
     breaks = 20,
     col = "lightblue",
     border = "white",
     cex.main = 1,
     cex.axis = 1,
     cex.lab = 1)

#5. Sleep Histogram

hist(phone$sleep,
     main = "Sleep",
     breaks = 20,
     col = "lightcoral",
     border = "white",
     cex.main = 1,
     cex.axis = 1,
     cex.lab = 1)

The first variable, phone use, is abnormally distributed, is positively skewed, and does not have a proper bell curve.

The second variable, sleep, is abnormally distributed, is negatively skewed, and does have a proper bell curve.

#7. Shapiro test

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

#Variable 1: Phone use #data: phone$phone #The first variable is abnormally distributed (p = .90) #W = 0.89755, p-value = 9.641e-09

#Variable 2: sleep #data: phone$sleep #The second variable is abnormally distributed. (p = .91) W = 0.91407, p-value = 8.964e-08

#9. Normality determined. Both historgrams are not normal and both SW tests are not normal.

#10. Use Spearman.

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

A Spearman correlation was conducted to test the relationship between phone use (Mdn = 3.27) and sleep (Mdn = 7.52). There was a statistically significant relationship between the two variables, p = -.65, p < .001. The relationship was negative and strong. As phone use increased, sleep decreased.