A café owner thinks if she can get customers to stay in her café longer, the customers will make more purchases. She plans to make the café more comfortable (add couches, more electrical outlets for laptops, etc) so customers stay longer. Before she makes this investment, the owner wants to check if her belief is true. She buys an AI software to collect information from her cash register and cameras to determine how long each customer stayed in the café and how many drinks they buy. Analyze the data to determine whether there is a relationship between time spent (minutes) in the shop and number of drinks purchased. Use the appropriate test to see if longer visits are associated with higher spending.
H0: There is no relationship between the customers who spent time in the cafe and number of drinks they purchased.
H1: There is a relationship between the customers who spent time in the cafe and number of drinks they purchase.
Load the packages
# Load required packages
library(readxl)
library(psych)
# Import the Excel file
A5RQ1 <- read_excel("C:/Users/sravz/Downloads/A5RQ1.xlsx")
Descriptive statistics
# calculate descriptive statistics
describe(A5RQ1[, 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
Histograms
hist(A5RQ1$Minutes,
main = "Histogram of V1",
xlab = "Value",
ylab = "Frequency",
col = "lightpink",
border = "black",
breaks = 20)
hist(A5RQ1$Drinks,
main = "Histogram of V2",
xlab = "Value",
ylab = "Frequency",
col = "lightgreen",
border = "black",
breaks = 20)
QUESTIONS
Q1) Check the SKEWNESS of the VARIABLE 1 histogram. In your opinion, does the histogram look symmetrical, positively skewed, or negatively skewed?
Histogram is positively skewed
Q2) Check the KURTOSIS of the VARIABLE 1 histogram. In your opinion, does the histogram look too flat, too tall, or does it have a proper bell curve?
It looks Too tall
Q3) Check the SKEWNESS of the VARIABLE 2 histogram. In your opinion, does the histogram look symmetrical, positively skewed, or negatively skewed?
Histogram is positively skewed
Q4) Check the KUROTSIS of the VARIABLE 2 histogram. In your opinion, does the histogram look too flat, too tall, or does it have a proper bell curve?
It looks Too tall
# Shapiro - wilk Normality Tests
shapiro.test(A5RQ1$Minutes)
##
## Shapiro-Wilk normality test
##
## data: A5RQ1$Minutes
## W = 0.84706, p-value < 2.2e-16
shapiro.test(A5RQ1$Drinks)
##
## Shapiro-Wilk normality test
##
## data: A5RQ1$Drinks
## W = 0.85487, p-value < 2.2e-16
QUESTIONS
Was the data normally distributed for Variable 1? It is NOT normally distributed
Was the data normally distributed for Variable 2? It is NOT normally distributed
Since both variables are NOT normally distributed , we will use spearman Correlation.
# Load required packages
library(ggplot2)
##
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
##
## %+%, alpha
library(ggpubr)
SCATTERPLOT
# create scatterplot with spearman correlation
ggscatter(A5RQ1, x = "Minutes", y = "Drinks",
add = "reg.line",
conf.int = TRUE,
cor.coef = TRUE,
cor.method = "spearman",
xlab = "Minutes in cafe", ylab = "Number of Drinks purchased",
title = "Relationship between time spent and Drinks purchased")
Is the relationship positive (line pointing up), negative (line pointing down), or is there no relationship (line is flat)?
The relaionship is positive (line pointing up)
# Conduct spearman correlation test
cor.test(A5RQ1$Minutes, A5RQ1$Drinks, method = "spearman")
## Warning in cor.test.default(A5RQ1$Minutes, A5RQ1$Drinks, method = "spearman"):
## Cannot compute exact p-value with ties
##
## Spearman's rank correlation rho
##
## data: A5RQ1$Minutes and A5RQ1$Drinks
## S = 1305608, p-value < 2.2e-16
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## 0.9200417
QUESTIONS
Q1) What is the direction of the effect?
A correlation of 0.92 is positive. As customers spent time in the cafe increases , number of drinks purchase increases.
Q2) What is the size of the effect?
A correlation of 0.92 is a strong relationship.
A Spearman correlation was conducted to assess the relationship between customer spent in the cafe and number of drinks purchase (n = 461).There was a statistically significant correlation between customer spent in the cafe (M = 29.89, SD = 18.63) and number of drinks purchased (M = 3.00, SD = 1.95).The correlation was positive and strong, rho = 0.92, p < 0.01. As customer spent in the cafe increases, number of drinks purchase increases.