DEPENDENT T-TEST & WILCOXON SIGN RANK
NULL HYPOTHESIS (H0)
There is no difference between sales before
campaign and after campaign.
ALTERNATE HYPOTHESIS (H1)
There is a difference between the sales
before campaign and after campaign
LOAD THE PACKAGE
library(readxl)
IMPORT EXCEL FILE INTO R STUDIO
dataset <- read_excel("C:\\Users\\burug\\Downloads\\A6R4.xlsx")
CALCULATE THE DIFFERENCE SCORES
Before <- dataset$PreCampaignSales
After <- dataset$PostCampaignSales
Differences <- After - Before
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: Positively Skewed
QUESTION 2: Did the histogram look too flat, too tall, or did it have
a proper bell curve?
ANSWER: Too flat
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<
0.04).
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?
ANSWER: One
Dot
QUESTION 2: Where are the dots in your boxplot?
One dot far to
whiskers
QUESTION 3: Based on the dots and there location, is the data
normal?
The data is not normal, dot is far away from whiskers.
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
LOAD THE PACKAGE
library(rstatix)
##
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
##
## filter
library(coin)
## Loading required package: survival
##
## Attaching package: 'coin'
## The following objects are masked from 'package:rstatix':
##
## chisq_test, friedman_test, kruskal_test, sign_test, wilcox_test
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
Q1) What is the size of the effect?
A Rank Biserial Correlation
of 0.261 indicates the difference between the sales before campaign and
after campaign is moderate.
Q2) Which group had the higher average
score?
The sales were moderately higher after campaign.
REPORT
A Wilcoxon Signed-Rank Test was conducted to compare sales
before campaign and after campaign. among 60 clothing stores. Median
before campaign were significantly lower (Md = 24624) than Median after
campaign (Md = 25086), V = 640, p = .0433. These results indicate that
the sales are moderately higher after campaign. The effect size was r =
0.261, indicating a moderate effect.