Research Scenario

A clothing company was to determine if the campaign featuring a famous actor was effective in increasing profits.

Hypothesis

Null Hpothesis (H0): There is no difference in sales before and after the campaign.
Alternate Hypothesis (H1): There is a difference in sales before and after the campaign.

Summary

A Wilcoxon Signed-Rank Test was conducted to compare the sales before and after marketing campaign with a famous actor. Median sales levels were higher after the campaign (Md = 25086) than before (Md = 24624), V = 640, p = 0.0433. These results indicate that the marketing campaign had an effect on the sales. The effect size was r = 0.261, indicating a moderate effect.

Within Groups

Code

# install.packages("readxl")
library(readxl)
A6R4 <- read_excel("C:/Users/armil/Downloads/A6R4.xlsx")

Descriptive Statistics

Before <- A6R4$PreCampaignSales
After <- A6R4$PostCampaignSales

Differences <- After - Before
# HISTOGRAM

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: Positively skewed. 

# QUESTION 2: Did the histogram look too flat, too tall, or did it have a proper bell curve?
# ANSWER: Too tall
# SHAPIRO-WILK TEST

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?
#  The data is abnormally distributed. So we will switch to Wilcoxon Sign Rank.
# BOXPLOT

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?
# There is one dot.

# QUESTION 2: Where are the dots in your boxplot?
# Close to the whiskers

# QUESTION 3: Based on the dots and there location, is the data normal?
# Data is normal. 
# DESCRIPTIVE STATISTICS

# 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
# EFFECT SIZE FOR WILCOXON SIGN RANK TEST

# install.packages("coin")

library(coin)
## Loading required package: survival
df_long <- data.frame(
   id = rep(1:length(Before), 2),
   time = rep(c("Before", "After"), each = length(Before)),
   score = c(Before, After)
)

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
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?
# effsize = 0.261, so the difference is moderate.  

# Q2) Which group had the higher average score?
# The after scores were higher.