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.
library(readxl)
A6R4 <- read_excel("C:\\Users\\kuppi\\OneDrive\\Desktop\\A6R4.xlsx")
Before <- A6R4$PreCampaignSales
After <- A6R4$PostCampaignSales
Differences <- After - Before
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 flat
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 not normal
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: No dots
QUESTION 2: Where are the dots in your boxplot?
QUESTION 3: Based on the dots and there location, is the data normal?
If there are no dots, the data is normal.
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
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
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
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 Examples: A Rank Biserial Correlation of 0.10 indicates the difference between the group averages was not truly meaningful. There was no effect. A Rank Biserial Correlation of 0.22 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.
A Wilcoxon Signed-Rank Test was conducted to compare store sales before and after the celebrity marketing campaign among 60 clothing stores. Median sales were significantly higher after the campaign (Md = 25,086) than before the campaign (Md = 24,624), V = 640, p = .0433. These results indicate that the marketing campaign produced a statistically significant increase in sales. The effect size was r = 0.26, indicating a moderate effect