Assignment 4

Question 2

Research Question

Is there a relationship between hours of sleep and hours of phone use?

Load Required Packages

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

Import Dataset

A4Q2 <-read_excel("C:/Users/rteno/Downloads/SLU/AA 5221-11 Applied Analytics and Methods - I/Week 4/Assignment 4/A4Q2.xlsx")
View(A4Q2)

Statistical Summary of Dataset

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

Descriptive Statistics for Sleep

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

Histograms

# 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.

Histogram for phone

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.

Scatter Plot

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

Based on this Shapiro.test result, both variables have p-value lower than 0.05 meaning that both of them are not normally distributed. # Therefore, a Spearman Correlation Test is more appropriate.

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

Interpretation:

A Spearman correlation was conducted to test the relationship between hours of sleep (Mdn = 7.52) and

hours of phone use (Mdn = 3.27).

There was a statistically significant relationship between the two variables, rs = -.615, p < .001.

The relationship was negative and strong.

As hours of sleep increased, hours of phone use decreased.