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 PreCampaign Sales and PostCampaign Sales.

ALTERNATE HYPOTHESIS (H1): There is a difference between the PreCampaign Sales and PostCampaign Sales.

library(readxl)


A6R4 <- read_excel("C:/Users/chkas/Downloads/A6R4.xlsx")


# CALCULATE THE DIFFERENCE SCORES
# Purpose: Calculate the difference between the Before scores versus the after scores.


Before <- A6R4$PreCampaignSales
After <- A6R4$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)

QUESTION 1: Is the histograms symmetrical, positively skewed, or negatively skewed? ANSWER: The histogram is Positively skewed

QUESTION 2: Did the histogram look too flat, too tall, or did it have a proper bell curve? ANSWER: The histogram looks too tall

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

QUESTION 1: Was the data normally distributed or abnormally distributed?

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).

ANSWER:The Data is abnormally distributed as p <0.05

# BOXPLOT
# Check for any outliers impacting the mean. 
# You do not need to edit this code

boxplot(Differences,
        main = "Distribution of Score Differences (After - Before)",
        ylab = "Difference in Scores",
        col = "blue",
        border = "darkblue")

QUESTION 1: How many dots are in your boxplot? A) No dots. B) One or two dots. C) Many dots.

ANSWER: There is one dot in the boxplot

QUESTION 2: Where are the dots in your boxplot? A) There are no dots. B) Very close to the whiskers (lines of the boxplot). C) Far from the whiskers (lines of the boxplot).

Answer: Far from the whiskers

QUESTION 3: Based on the dots and there location, is the data normal? If there are no dots, the data is normal. If there are one or two dots and they are CLOSE to the whiskers, the data is normal If there are many dots (more than one or two) and they are FAR AWAY from the whiskers, this means data is NOT normal. Switch to a Wilcoxon Sign Rank. Anything else could be normal or abnormal. Check if there is a big difference between the median and the mean. If there is a big difference, the data is not normal. If there is a small difference, the data is normal.

Answer: The Data is not normal

# 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
# You do not need to edit this code

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
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

install.packages(“rstatix”)

install.packages(‘coin’)

# LOAD THE PACKAGE
# Always reload the package you want to use. 

library(rstatix)
## 
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
## 
##     filter
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 Answer the questions below as a comment within the R script: Q1) What is the size of the effect? ± 0.00 to 0.09 = small ± 0.10 to 0.29 = moderate ± 0.30 to 0.49 = large ± 0.50 to 1.00 = very large

Answer: A Rank Biserial Correlation of 0.26 indicates the difference between the group averages was small.

Q2) Which group had the higher average score? - With the way we calculated differences (After minus Before), if it is positive, it means the After scores were higher. - If it is negative, it means the Before scores were higher. - You can also easily look at the means and tell which scores were higher.

Answer- After scores are higher as the the difference is positive and also the mean for After scores are higher

SUMMARY OF RESULTS

A Wilcoxon Signed-Rank Test was conducted to compare stress levels before and after Campaign Sales among 60 participants. Median stress levels were significantly higher after the training (Md = 25086) than before (Md = 24624) V = 640, p = 0.04. The results indicate that the Campaign Sales significantly increased sales. The effect size was r = 0.26, indication a small effect Overall, the campaign appeared to have a measurable and meaningful positive impact on sales.