DEPENDENT T-TEST & WILCOXON SIGN RANK

Used to test if there is a difference between Before Pre training and Post training After scores (comparing the means).

NULL HYPOTHESIS (H0)

There is no difference between the Pre training and Post training

ALTERNATE HYPOTHESIS (H1)

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")

CALCULATE THE DIFFERENCE SCORES

Before <- dataset$PreTraining
After <- dataset$PostTraining

Differences <- After - Before

HISTOGRAM

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-WILK TEST

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

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.

DESCRIPTIVE STATISTICS

DESCRIPTIVES FOR BEFORE SCORES

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

DESCRIPTIVES FOR AFTER SCORES

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