# Load required packages
library(readxl)
library(psych)
library(ggplot2)
library(ggpubr)

Test the relationship between two continuous variables (Minutes and Drinks).

HYPOTHESES

H0: There is no relationship between Minutes and Drinks.

H1: There is a relationship between Minutes and Drinks.

Directional: As Minutes increase, Drinks increase OR decrease.


Import Data

dataset <- read_excel("C:/Users/konifade/Downloads/A5RQ1.xlsx")
head(dataset)
## # A tibble: 6 × 3
##   Customer Minutes Drinks
##      <dbl>   <dbl>  <dbl>
## 1        1    26.9      3
## 2        2    21.5      2
## 3        3    36.6      3
## 4        4    10.6      1
## 5        5    11.1      1
## 6        6    16.3      1

Descriptive Statistics

describe(dataset[, c("Minutes", "Drinks")])
##         vars   n  mean    sd median trimmed   mad min   max range skew kurtosis
## Minutes    1 461 29.89 18.63   24.4   26.99 15.12  10 154.2 144.2 1.79     5.20
## Drinks     2 461  3.00  1.95    3.0    2.75  1.48   0  17.0  17.0 1.78     6.46
##           se
## Minutes 0.87
## Drinks  0.09

COMMENTED RESULTS

Minutes: M = 29.89, SD = 18.63, skew = 1.79, kurtosis = 5.20

Drinks: M = 3.00, SD = 1.95, skew = 1.78, kurtosis = 6.46

Both variables are positively skewed and leptokurtic (too tall).


Normality Check

# Histograms
hist(dataset$Minutes,
     main = "Histogram of Minutes",
     xlab = "Value", ylab = "Frequency",
     col = "lightblue", border = "black", breaks = 20)

hist(dataset$Drinks,
     main = "Histogram of Drinks",
     xlab = "Value", ylab = "Frequency",
     col = "lightgreen", border = "black", breaks = 20)

# Shapiro-Wilk tests
shapiro.test(dataset$Minutes)
## 
##  Shapiro-Wilk normality test
## 
## data:  dataset$Minutes
## W = 0.84706, p-value < 2.2e-16
shapiro.test(dataset$Drinks)
## 
##  Shapiro-Wilk normality test
## 
## data:  dataset$Drinks
## W = 0.85487, p-value < 2.2e-16

COMMENTED RESULTS

Minutes: W = 0.84706, p < 2.2e-16 → Not normally distributed

Drinks: W = 0.85487, p < 2.2e-16 → Not normally distributed


Scatterplot

ggscatter(dataset, x = "Minutes", y = "Drinks",
          add = "reg.line", conf.int = TRUE,
          cor.coef = TRUE, cor.method = "spearman",
          xlab = "Variable Minutes", ylab = "Variable Drinks")

COMMENTED RESULTS

The relationship is positive. The regression line slopes upward.

Spearman correlation (ρ = 0.92, p < 2.2e-16) confirms a strong, statistically significant positive association.


Correlation Tests

# Pearson correlation
cor.test(dataset$Minutes, dataset$Drinks, method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  dataset$Minutes and dataset$Drinks
## t = 68.326, df = 459, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.9452363 0.9617123
## sample estimates:
##       cor 
## 0.9541922

COMMENTED RESULTS

Pearson correlation: r = 0.95, df = 459, p < 2.2e-16

95% CI [0.945, 0.962]

Statistically significant (p < .001).

Strong, positive correlation between Minutes and Drinks.


Final Report (as Comments)

A Spearman correlation was conducted to assess the relationship between Minutes and Drinks (n = 461).

Descriptive statistics showed that Minutes had a mean of 29.89 (SD = 18.63),

and Drinks had a mean of 3.00 (SD = 1.95).

Shapiro-Wilk tests indicated both variables were not normally distributed (p < .001).

There was a statistically significant correlation between Minutes and Drinks.

The correlation was positive and strong, ρ(459) = 0.92, p < .001.

As time spent increases, the number of drinks consumed also increases.

For comparison, a Pearson correlation yielded similar results:

r(459) = 0.95, p < .001, confirming a strong linear association.

```