Used to test if there is a difference between Before Pre training and Post training After scores (comparing the means).
There is no difference between the Pre training and Post training
There is a difference between the Pre training and Post training
#install.packages("readxl")
library(readxl)
dataset <- read_excel("C:\\Users\\navya\\Downloads\\A6R3.xlsx")
Before <- dataset$PreTraining
After <- dataset$PostTraining
Differences <- After - Before
hist(Differences,
main = "Histogram of Difference Scores",
xlab = "Value",
ylab = "Frequency",
col = "blue",
border = "black",
breaks = 20)
# DIRECTIONS: Answer the questions below directly in your code.
# QUESTION 1: Is the histograms symmetrical, positively skewed, or negatively skewed?
# ANSWER: The histogram appears positively skewed.
# QUESTION 2: Did the histogram look too flat, too tall, or did it have a proper bell curve?
# ANSWER: The histogram appears irregular and flattened which does not form a perfect bell curve
shapiro.test(Differences)
##
## Shapiro-Wilk normality test
##
## data: Differences
## W = 0.98773, p-value = 0.21
# DIRECTIONS: Answer the questions below directly in your code.
# 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:
# Since p value is 0.21 where p>0.05 it is normally distributed so we can continue with dependent t-test.
boxplot(Differences,
main = "Distribution of Score Differences (After - Before)",
ylab = "Difference in Scores",
col = "blue",
border = "darkblue")
# DIRECTIONS: Answer the questions below directly in your code.
# QUESTION 1: How many dots are in your boxplot?
# A) No dots.
# B) One or two dots.
# C) Many dots.
# ANSWER: B
# 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: B
# 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 dot is closed to the Whisker. In Shapiro Wilk test as p=0.21 which is >0.05 where it is normal. So, we can continue with dependent t-test.
mean(Before, na.rm = TRUE)
## [1] 59.73333
median(Before, na.rm = TRUE)
## [1] 60
sd(Before, na.rm = TRUE)
## [1] 7.966091
length(Before)
## [1] 150
mean(After, na.rm = TRUE)
## [1] 69.24
median(After, na.rm = TRUE)
## [1] 69.5
sd(After, na.rm = TRUE)
## [1] 9.481653
length(After)
## [1] 150
t.test(Before, After, paired = TRUE)
##
## Paired t-test
##
## data: Before and After
## t = -23.285, df = 149, p-value < 2.2e-16
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## -10.313424 -8.699909
## sample estimates:
## mean difference
## -9.506667
Purpose: Determine how big of a difference there was between the group means.
#install.packages("effectsize")
library(effectsize)
cohens_d(Before, After, paired = TRUE)
## For paired samples, 'repeated_measures_d()' provides more options.
## Cohen's d | 95% CI
## --------------------------
## -1.90 | [-2.17, -1.63]
QUESTION 1: What is the size of the effect? Since Cohen’s d value is 1.90 >1.30, effect size is very large.
QUESTION 2: Which group had the higher average score? YOUR ANSWER: Since the effect size was negative,before scores were higher than after scores.
#A dependent t-test was conducted to compare pre-training and post-training scores among the 150 participants. The results showed that post-training scores (69.24,SD=9.48) were significantly higher than pre-training scores(M=59.73,SD=7.97),indicating improvement after training. The analysis revealed a statistically significant difference between the two points, t(149)=-23.29, p<0.001, with an average increase of 9.51 points from before to after training. The effect size was Cohen’s d=1.90, indicating a very large effect, meaning that the training produced a strong and meaningful improvement in participant scores.
wilcox.test(Before, After, paired = TRUE)
##
## Wilcoxon signed rank test with continuity correction
##
## data: Before and After
## V = 43, p-value < 2.2e-16
## alternative hypothesis: true location shift is not equal to 0
#install.packages("rstatix")
#install.packages('coin')
library(rstatix)
##
## Attaching package: 'rstatix'
## The following objects are masked from 'package:effectsize':
##
## cohens_d, eta_squared
## 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.861 150 150 large
Q1) What is the size of the effect? Answer: The Rank biserial
correlation was 0.861 so it is between ± 0.50 to 1.00 = very large
Q2) Which group had the higher average score? The effect size was
positive which is 0.861, which indicates that the After scores were
higher than the Before scores.So, After group had the higher average
scores.
A Wilcoxon signed rank test was conducted to compare before and after scores intervention between 150 participants. Mean scores were Md_before=60 and Md_after=69.5. The test revealed a statistically significant difference between two time points, V=43,p<0.001. These results indicate that there was a significant increase in scores from before to after. The effect size was a rank bivariate correlation of 0.861, indicating a very large effect.