R PROCESS
IMPORT EXCEL FILE & CALCULATE THE DIFFERENCES
library(readxl)
A6R4 <- read_excel("D:/000 20251021 AA 5221 Applied Analytics & Methods 1/Week 6/A6R4.xlsx")
Before <- A6R4$PreCampaignSales
After <- A6R4$PostCampaignSales
Differences <- After - Before
print(Differences)
## [1] 21095 971 6697 -2883 6805 -9116 -894 432 5517 -2788 -3617 -1116
## [13] 789 9864 1986 219 5062 10671 5222 1844 -3527 2897 2774 -1004
## [25] 5591 -4039 -1855 -2478 456 595 -2230 176 6574 -7993 -1991 15424
## [37] 1396 10423 1120 -2109 -1941 -2867 7956 5925 -5545 858 7049 7061
## [49] 285 -247 -3229 2350 2043 3736 6813 1658 -144 2323 -7760 -149
CHECK THE NORMALITY OF THE DIFFERENCE
CREATE A HISTOGRAM FOR THE DIFFERENCES DATA
hist(Differences,
main = "Histogram of Difference Before and After training",
xlab = "Value",
ylab = "Frequency",
col = "blue",
border = "black",
breaks = 20)

QUESTION 1: Is the histogram symmetrical, positively skewed, or
negatively skewed?
ANSWER: The histogram is not symmetrical, it is positive skwed
QUESTION 2: Did the histogram look too flat, too tall, or did it
have a proper bell curve?
ANSWER: The histogram has a proper bell curve
SHAPIRO-WILK TEST
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?
ANSWER: The data is abnormally distributed, p < .05 (p =
.012)
CREATE BOX PLOTS
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?
ANSWER: There is one dot outside of the whiskers
QUESTION 2: Where are the dots in your boxplot?
ANSWER: It is far from the whiskers
QUESTION 3: Based on the dots and there location, is the data
normal?
ANSWER: The data is NOT normal
DESCRIPTIVE STATISTIC
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
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
WILCOXIN SIGN RANK TEST
t.test(Before, After, paired = TRUE)
##
## Paired t-test
##
## data: Before and After
## t = -2.4626, df = 59, p-value = 0.01673
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## -3115.6567 -322.1766
## sample estimates:
## mean difference
## -1718.917
Question:
Answer: Test is statistically significant p < .05 (P = .043)
EFFECT SIZE:
library(rstatix)
##
## Attaching package: 'rstatix'
## 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
REPORT PARAGRAPH
A Wilcoxon Signed-Rank Test was conducted to compare sales revenue
data before and after the marketing campaign
among 60 stores. Median sales revenue was higher after the marketing
campaign (Md = $25086) than before (Md = $24624),
V = 640, p = .043. These results indicate that the sales revenue
after the marketing campaign was increased than before the campaign
The effect size was r = 0.26, indicating a moderate effect.