library(readxl)
library(ggpubr)
## Loading required package: ggplot2
phone <- read_excel("phone.xlsx")
library(ggpubr)
ggscatter(
data = phone,
x = "phone",
y = "sleep",
add = "reg.line",
xlab = "Phone Use",
ylab = "Sleep"
)
Scatterplot creation and intrpretation. The relationship is linear, negative, strong, with minor outliers. Data reflects negative linear relationship requiring pearson.
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
hist(phone$phone,
main = "Phone Use",
breaks = 20,
col = "lightblue",
border = "white",
cex.main = 1,
cex.axis = 1,
cex.lab = 1)
hist(phone$sleep,
main = "Sleep",
breaks = 20,
col = "lightcoral",
border = "white",
cex.main = 1,
cex.axis = 1,
cex.lab = 1)
Variable 1: Phone use. The first variable appears abnormally distributed. The data appears postively skewed. The data does not have a proper bell curve.
Variable 2: sleep The first variable looks abnormally distributed. The data is negatively skewed.The data does not have a proper bell curve.
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. The first variable is abnormally distributed (p = .90) Variable 2: Sleep. The second variable is abnormally distributed. (p = .91)
Normality determined. Both historgrams are not normal and SW tests are not nomral.
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 < .001, p < .001. The relationship was negative] and strong.
As the phone use increased, sleep decreased.