Is there a relationship between hours of sleep and hours of phone use?
library (readxl)
## Warning: package 'readxl' was built under R version 4.6.1
library (ggpubr)
## Warning: package 'ggpubr' was built under R version 4.6.1
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 4.6.1
A4Q2 <-read_excel("C:/Users/rteno/Downloads/SLU/AA 5221-11 Applied Analytics and Methods - I/Week 4/Assignment 4/A4Q2.xlsx")
View(A4Q2)
summary(A4Q2)
## sleep phone
## Min. : 2.000 Min. : 0.2608
## 1st Qu.: 6.931 1st Qu.: 1.9057
## Median : 7.524 Median : 3.2708
## Mean : 7.559 Mean : 3.8046
## 3rd Qu.: 8.372 3rd Qu.: 4.8773
## Max. :10.089 Max. :15.0000
mean(A4Q2$sleep)
## [1] 7.559076
sd(A4Q2$sleep)
## [1] 1.208797
median(A4Q2$sleep)
## [1] 7.524099
# Descriptive Statistics for Phone
mean(A4Q2$phone)
## [1] 3.804609
sd(A4Q2$phone)
## [1] 2.661866
median(A4Q2$phone)
## [1] 3.270839
# Histogram for sleep
hist(A4Q2$sleep, main = "Hours of Sleep", xlab = "Sleep", col = "brown",border = "white", breaks = 20 )
# Number of hours of sleep is not normally distributed # There are some
unusual low values on the distribution and not fully curved.
hist(A4Q2$phone, main = "Hours of Phone Use", xlab = "Phone", col = "darkgreen",border = "white", breaks = 20 )
# Number of hours of phone use is not normally distributed # The
distribution is positively skewed and not fully curved.
ggscatter(A4Q2, x="sleep", y="phone", add = "reg.line", xlab = "Hours of sleep", ylab = "Hours of Phone Use")
# The relationship is negative #There are no outliers. #The relationship
appears monotonic ### Normality Test Run
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
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