Import Datasets

library(readxl)
DatasetB <- read_excel("D:/SLU/AdvAppliedAnalytics/DatasetB.xlsx")

Calculate mean and standard deviation

  1. Screen Time - Independent Variable
mean(DatasetB$ScreenTime)
## [1] 5.063296
sd(DatasetB$ScreenTime)
## [1] 2.056833

The independent variable is Screen Time had a mean of 5.06 and a standard deviation of 2.06

  1. Sleeping Hours - Dependent Variable
mean(DatasetB$SleepingHours)
## [1] 6.938459
sd(DatasetB$SleepingHours)
## [1] 1.351332

Create Histograms for IV - Screen Time

hist(DatasetB$ScreenTime,
     main = "ScreenTime",
     breaks = 20,
     col = "lightblue",
     border = "white",
     cex.main = 1,
     cex.axis = 1,
     cex.lab = 1)

The variable “Screen Time” appears positively skewed (most data is in the left). The data also appears does not have proper bell curve.

Create Histograms for DV - Sleeping Hours

hist(DatasetB$SleepingHours,
     main = "SleepingHours",
     breaks = 20,
     col = "lightblue",
     border = "white",
     cex.main = 1,
     cex.axis = 1,
     cex.lab = 1)

The variable “Sleeping Hours” appears normally distributed. The data looks symmetrical (most data is in the middle). The data also appears to have a proper bell curve.

Conduct Shapiro–Wilk tests for to check the normality of each variable

  1. ScreenTime
shapiro.test(DatasetB$ScreenTime) 
## 
##  Shapiro-Wilk normality test
## 
## data:  DatasetB$ScreenTime
## W = 0.90278, p-value = 1.914e-06

The Shaprio-Wilk p-value for ScreenTime normality test is less than 0.05, so the data is not normal

  1. SleepingHours
shapiro.test(DatasetB$SleepingHours)
## 
##  Shapiro-Wilk normality test
## 
## data:  DatasetB$SleepingHours
## W = 0.98467, p-value = 0.3004

The Shaprio-Wilk p-value for SleepingHours normality test is greater than 0.05 (0.3), so the data is normal

Correlation Analysis

cor.test(DatasetB$ScreenTime, DatasetB$SleepingHours, method = "spearman")
## 
##  Spearman's rank correlation rho
## 
## data:  DatasetB$ScreenTime and DatasetB$SleepingHours
## S = 259052, p-value = 3.521e-09
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##        rho 
## -0.5544674

The Spearman Correlation test was selected because one of the variables was abnormally distributed according to the histograms and the Shapiro-Wilk tests. The p-value (probability value) is 3.521e-09, which is below 0.05. This means the results are statistically significant. The alternate hypothesis is supported. The rho-value is -0.5544674 The correlation is negative, which means as ScreenTime increases the SleepingHours decreases. The correlation value is greater -0.50, which means the relationship is strong.

Scatterplots

library(ggpubr)
## Loading required package: ggplot2
ggscatter(
  DatasetB,
  x = "ScreenTime",
  y = "SleepingHours",
  add = "reg.line",
  xlab = "Independent Variable",
  ylab = "Dependent Variable"
)

The line of best fit is pointing downward from left to right. This means the direction of the data is negative. As screen time increases, sleeping hours decrease. The dots moderately follow the line of best fit, indicating a moderate relationship between the variables. The dots form approximately straight-line pattern, showing that the data is linear. There may be a few possible outliers (individuals with high screen time but relatively higher sleeping hours); however, these points are still close to the line of best fit and do not significantly affect the overall relationship between screen time and sleeping hours.

Results Description

A Spearman correlation analysis was conducted to examine the relationship between Screen Time and Sleeping Hours The independent variable is Screen Time had a mean of 5.06 and a standard deviation of 2.06 The dependent variable is Sleeping Hours had mean of 6.94 and a standard deviation of 1.35 Correlation coefficient rho = -0.55, p-value = 3.521e-09 which is less than 0.05 The relationship was negative and strong. As Screen Time increased the Sleeping Time decreased.

Results Report

Screen Time (M = 5.06, SD = 2.06) was correlated with Sleeping Hours (M = 6.94, SD = 1.35), ρ = -0.55, p < 0.001 The relationship was negative and strong. As the screen time increased the hours sleeping decreased.