Scenario 4: Sustainability Initiatives and Brand Loyalty
A clothing company recently launched a marketing campaign featuring a famous actor. The goal was to increase profits (USD) by associating the brand with a well-liked celebrity. After the campaign, the company wants to determine if the campaign was effective. The company has data for 60 clothing stores. Did the sales increase after the campaign?
NULL HYPOTHESIS (H0)
There is no difference between the Before scores and After scores.
ALTERNATE HYPOTHESIS (H1)
There is a difference between the Before scores and After scores.
IMPORT EXCEL FILE
Import your Excel dataset into R to conduct analyses.
INSTALL REQUIRED PACKAGE
options(repos = c(CRAN = "https://cloud.r-project.org"))
install.packages("readxl")
## Installing package into 'C:/Users/N Geetha Shivani/AppData/Local/R/win-library/4.5'
## (as 'lib' is unspecified)
## package 'readxl' successfully unpacked and MD5 sums checked
## Warning: cannot remove prior installation of package 'readxl'
## Warning in file.copy(savedcopy, lib, recursive = TRUE): problem copying
## C:\Users\N Geetha
## Shivani\AppData\Local\R\win-library\4.5\00LOCK\readxl\libs\x64\readxl.dll to
## C:\Users\N Geetha
## Shivani\AppData\Local\R\win-library\4.5\readxl\libs\x64\readxl.dll: Permission
## denied
## Warning: restored 'readxl'
##
## The downloaded binary packages are in
## C:\Users\N Geetha Shivani\AppData\Local\Temp\RtmpwnXvVt\downloaded_packages
LOAD THE PACKAGE
library(readxl)
IMPORT EXCEL FILE INTO R STUDIO
dataset <- read_excel("C:\\Users\\N Geetha Shivani\\Downloads\\A6R4.xlsx")
CALCULATE THE DIFFERENCE SCORES
Purpose: Calculate the difference between the Before scores versus the after scores.
Before <- dataset$PreCampaignSales
After <- dataset$PostCampaignSales
Differences <- After - Before
HISTOGRAM
Create a histogram for difference scores to visually check skewness and kurtosis.
CREATE THE HISTOGRAMS
hist(Differences,
main = "Histogram of Difference Scores",
xlab = "Value",
ylab = "Frequency",
col = "blue",
border = "black",
breaks = 20)
QUESTIONS
QUESTION 1: Is the histograms symmetrical, positively skewed, or negatively skewed?
A)The histogram looks positively skewed.
QUESTION 2: Did the histogram look too flat, too tall, or did it have a proper bell curve?
A)The histogram does not have a proper bell-shaped curve.
SHAPIRO-WILK TEST
Check the normality for the difference between the groups.
shapiro.test(Differences)
##
## Shapiro-Wilk normality test
##
## data: Differences
## W = 0.94747, p-value = 0.01186
QUESTIONS
QUESTION 1: Was the data normally distributed or abnormally distributed?
NOTE:If p > 0.05 (P-value is GREATER than .05) this means the data is NORMAL (continue with Dependent t-test).If p < 0.05 (P-value is LESS than .05) this means the data is NOT normal (switch to Wilcoxon Sign Rank).
A)The data is abnormally distributed because p<.05.
BOXPLOT
Check for any outliers impacting the mean.
boxplot(Differences,
main = "Distribution of Score Differences (After - Before)",
ylab = "Difference in Scores",
col = "blue",
border = "darkblue")
QUESTIONS
QUESTION 1: How many dots are in your box plot?
A)One or two dots
QUESTION 2: Where are the dots in your box plot?
A)Far away from the whiskers (lines of the box plot).
QUESTION 3: Based on the dots and there location, is the data normal?
A)Based on the box plot,we cannot determine if the data is normal or abnormal.
DESCRIPTIVE STATISTICS
Calculate the mean, median, SD, and sample size for each group.
DESCRIPTIVES FOR BEFORE SCORES
mean(Before, na.rm = TRUE)
## [1] 25154.53
median(Before, na.rm = TRUE)
## [1] 24624
sd(Before, na.rm = TRUE)
## [1] 12184.4
length(Before)
## [1] 60
DESCRIPTIVES FOR AFTER SCORES
mean(After, na.rm = TRUE)
## [1] 26873.45
median(After, na.rm = TRUE)
## [1] 25086
sd(After, na.rm = TRUE)
## [1] 14434.37
length(After)
## [1] 60
WILCOXON SIGN RANK TEST
wilcox.test(Before, After, paired = TRUE)
##
## Wilcoxon signed rank test with continuity correction
##
## data: Before and After
## V = 640, p-value = 0.0433
## alternative hypothesis: true location shift is not equal to 0
DETERMINE STATISTICAL SIGNIFICANCE
If results were statistically significant (p < .05), continue to effect size section below.
If results were NOT statistically significant (p > .05), skip to reporting section below.
NOTE: Getting results that are not statistically significant does NOT mean you switch to Wilcoxon Sign Rank.The Wilcoxon Sign Rank test is only for abnormally distributed data — not based on outcome significance.
EFFECT SIZE FOR WILCOXON SIGN RANK TEST
Purpose: Determine how big of a difference there was between the group means.
INSTALL REQUIRED PACKAGE
install.packages("coin")
## Installing package into 'C:/Users/N Geetha Shivani/AppData/Local/R/win-library/4.5'
## (as 'lib' is unspecified)
## package 'coin' successfully unpacked and MD5 sums checked
## Warning: cannot remove prior installation of package 'coin'
## Warning in file.copy(savedcopy, lib, recursive = TRUE): problem copying
## C:\Users\N Geetha
## Shivani\AppData\Local\R\win-library\4.5\00LOCK\coin\libs\x64\coin.dll to
## C:\Users\N Geetha
## Shivani\AppData\Local\R\win-library\4.5\coin\libs\x64\coin.dll: Permission
## denied
## Warning: restored 'coin'
##
## The downloaded binary packages are in
## C:\Users\N Geetha Shivani\AppData\Local\Temp\RtmpwnXvVt\downloaded_packages
install.packages("rstatix")
## Installing package into 'C:/Users/N Geetha Shivani/AppData/Local/R/win-library/4.5'
## (as 'lib' is unspecified)
## package 'rstatix' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\N Geetha Shivani\AppData\Local\Temp\RtmpwnXvVt\downloaded_packages
LOAD THE PACKAGE
library(coin)
## Loading required package: survival
library(rstatix)
##
## Attaching package: 'rstatix'
## The following objects are masked from 'package:coin':
##
## chisq_test, friedman_test, kruskal_test, sign_test, wilcox_test
## The following object is masked from 'package:stats':
##
## filter
CALCULATE RANK BISERIAL CORRELATION (EFFECT SIZE)
df_long <- data.frame(
id = rep(1:length(Before), 2),
time = rep(c("Before", "After"), each = length(Before)),
score = c(Before, After)
)
wilcox_effsize(df_long, score ~ time, paired = TRUE)
## # A tibble: 1 × 7
## .y. group1 group2 effsize n1 n2 magnitude
## * <chr> <chr> <chr> <dbl> <int> <int> <ord>
## 1 score After Before 0.261 60 60 small
QUESTION
Q1) What is the size of the effect?
Q2) Which group had the higher average score?
A)The post campaign sales have higher average score.
SUMMARY OF RESULTS
A Wilcoxon Signed-Rank Test was performed to compare sales before and after the marketing campaign for the clothing company. Median sales prior to the campaign (Md = 24,624) were significantly lower than median sales afterward (Md = 25,086), V = 640, p = 0.0433. The effect size was r = 0.261, reflecting a moderate change between the two time points. These findings indicate that sales increased following the marketing campaign.